mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: Christian Brauner <brauner@kernel.org>,
	Daniel Wade <danjwade95@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Darren Hart <dvhart@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	Andre Almeida <andrealmeid@igalia.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Kyle Zeng <kylebot@openai.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] futex/pi: Reject owners that have no mm
Date: Tue, 01 Dec 2026 22:25:38 +0100	[thread overview]
Message-ID: <87v75cofql.ffs@fw13> (raw)
In-Reply-To: <20261201-fotoreporter-fastnacht-siegreich-312e2a63bbba@brauner>

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.


  reply	other threads:[~2026-12-01 21:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 13:26 Daniel Wade
2026-11-30 14:00 ` Thomas Gleixner
2026-12-01 20:31   ` Christian Brauner
2026-12-01 21:25     ` Thomas Gleixner [this message]
2026-12-01 23:42       ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v75cofql.ffs@fw13 \
    --to=tglx@kernel.org \
    --cc=andrealmeid@igalia.com \
    --cc=bigeasy@linutronix.de \
    --cc=brauner@kernel.org \
    --cc=danjwade95@gmail.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=kylebot@openai.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®