Re: [PATCH 2/2] futex: Leave the pi lock stealer in a consistent state upon successful fault
From: Davidlohr Bueso
Date: Tue Mar 16 2021 - 14:04:51 EST
On Tue, 16 Mar 2021, Peter Zijlstra wrote:
IIRC we made the explicit choice to never loop here. That saves having
to worry about getting stuck in in-kernel loops.
Userspace triggering the case where the futex goes corrupt is UB, after
that we have no obligation for anything to still work. It's on them,
they get to deal with the bits remaining.
I was kind of expecting this answer, honestly. After all, we are warned
about violations to the 10th:
*  There is no transient state which leaves owner and user space
* TID out of sync. Except one error case where the kernel is denied
* write access to the user address, see fixup_pi_state_owner().
(btw, should we actually WARN_ON_ONCE this case such that the user is
well aware things are screwed up?)
However, as 34b1a1ce145 describes, it was cared enough about users to
protect them against spurious runaway tasks. And this is why I decided
to even send the patch; it fixes, without sacrificing performance or
additional complexity, a potentially user visible issue which could be
due to programming error. And unlike 34b1a1ce145, where a stealer that
cannot fault ends up dropping the lock, here the stealer can actually
amend things and not break semantics because of another task's stupidity.
But yeah, this could also be considered in the category of inept attempts
to fix a rotten situation.