Re: [PATCH] futex/pi: Reject owners that have no mm
From: Thomas Gleixner
Date: Tue Dec 01 2026 - 16:25:48 EST
On Tue, Dec 01 2026 at 21:31, Christian Brauner wrote:
> On Mon, Nov 30, 2026 at 03:00:46PM +0100, Thomas Gleixner wrote:
>> Why putting this into the pi_lock held region? p->pi_lock protects
>> nothing here and the access to p->mm is racy in any case and will
>> trigger KCSAN splats.
>>
>> So the below is sufficient.
>
> I'm not sure. I found the same bug while working on cleaning up exec
> again. Afaict, checking p->mm before the futex state check breaks exit
> race handling. But I'm not an expert so double-check. An exiting task
> drops its mm after its futex state went to FUTEX_STATE_DEAD:
>
> do_exit()
> -> exit_mm()
> -> mm_exit_exec_release()
> -> futex_exit_exec_release()
> -> futex_cleanup_end() // FUTEX_STATE_DEAD
> -> current->mm = NULL
>
> and it can still be found by its TID until it's reaped. IOW, a task that
> has just exited also has no mm, because exit_mm() sets current->mm =
> NULL after the futex state went DEAD. So a dead owner hits the new check
> and the waiter gets -EPERM which means glibc aborts. So I think this
> breaks things.
Fair enough.
> Checking under pi_lock means a dead task returns at the state check and
> never reaches it. Only state OK with no mm gets -EPERM which is a umh
> tha that never exec'ed.
But that really needs to be spelled out in the change log and comments.