Re: [PATCH] futex/pi: Reject owners that have no mm
From: Christian Brauner
Date: Wed Dec 02 2026 - 02:56:40 EST
On Wed, Dec 02, 2026 at 12:42:01AM +0100, Thomas Gleixner wrote:
> On Tue, Dec 01 2026 at 22:25, Thomas Gleixner wrote:
> > On Tue, Dec 01 2026 at 21:31, Christian Brauner wrote:
> >> 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.
>
> I just read it again and it was spelled out in the change log in passing
> in the last sentence but then the comment in the patch really confused
> me.
>
> But what really bothers me is the fact that the fix focusses on that
> particular exit issue which makes the kernel go belly up.
>
> Though it does not address the actually underlying problem:
>
> task::futex::state is unconditionally initializied to FUTEX_STATE_OK
> in copy_process().
>
> That was "correct" before the private hash came around, but only if
> "correct" is defined as "does not explode".
>
> So I rather go and make this very explicit and not focussed on the
> potential exit/exec cleanup accessing current->mm.
Sounds great.