From: Thomas Gleixner <tglx@kernel.org>
To: Keno Fischer <keno@juliahub.com>
Cc: "Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"André Almeida" <andrealmeid@igalia.com>,
"Yang Tao" <yang.tao172@zte.com.cn>,
"Yi Wang" <wang.yi59@zte.com.cn>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
stable@vger.kernel.org, "Florian Weimer" <fweimer@redhat.com>,
"Oleg Nesterov" <oleg@redhat.com>,
"Christian Brauner" <brauner@kernel.org>
Subject: Re: [PATCH] futex: Make FUTEX_WAITERS state consistent for robust futex unlock
Date: Fri, 31 Jul 2026 12:41:23 +0200 [thread overview]
Message-ID: <87a4r7fnl8.ffs@fw13> (raw)
In-Reply-To: <CABV8kRws040xRZqsLdDJNaHs-3Ax063uQnqTR-1mMMmkaCq3ow@mail.gmail.com>
On Fri, Jul 31 2026 at 00:36, Keno Fischer wrote:
> Thanks for the detailed changelog - I think it lays everything out very nicely.
> The optimization added in this revision isn't quite sound as written, but should
> be easy to fix - see below. Just a few minor nits on the changelog language
> otherwise.
>
> On Thu, Jul 30, 2026 at 6:15 PM Thomas Gleixner <tglx@kernel.org> wrote:
>> Keno reported another subtle futex exit race, which is neither handled by
>> commit 3ca9595d9fb6 ("futex: Add support for unlocking robust futexes") nor
>> by the recent efforts around commit 3ca9595d9fb6 ("futex: Add support for
>> unlocking robust futexes").
>
> Duplicate shas - ca16d5bee598 ("futex: Prevent robust futex exit
> race") for the first one?
Wanted to referrence ca16d5bee598 ("futex: Prevent robust futex exit
race") obviously.
>> Amend that proceedure so it does the following steps:
>
> typo
>
>> 4) Try to unlock the user space lock value either with 0 or
>> FUTEX_WAITERS according to the result of #3
>
> I think it would be good to note here (or in robust-futex-ABI.rst)
> that this is a change to the non-PI futex protocol ABI so that userspace
> can appropriately coordinate the ABI versioning when adopting
> FUTEX_ROBUST_UNLOCK.
Makes sense
>> As #3 and #6 seem to be redundant operations they are not because as
>> explained above the elegible waiters cannot be collected into the wake
>> queue before the to be set state of the FUTEX_WAITERS bit has been
>> established.
>
> typo 'elegible' -> 'eligible'; same in the paragraph below this
>
>> + /*
>> + * Waiters are counted independent of the bitset match. Stop the
>> + * list walk when the total number of waiters becomes larger
>> + * than the number of to be woken up tasks. In that case it does
>> + * not matter how many wakees have been found. There will be
>> + * waiters queued after the wake up no matter what.
>> + */
>> + if (++waiters > nr_wake)
>> + return 1;
>
> On bitset mismatch, this will early-out before caching the wakee below, losing
> the wake.
Duh. Heat induced brain fart.
>> + /*
>> + * This should never happen because evaluate_waiters() would
>> + * have detected a PI futex mixup already.
>> + */
>> + if (WARN_ON_ONCE(nr_woken < 0))
>> + return nr_woken;
>
> I missed this before, but the same issue makes this WARN reachable. If there's
> a bunch of bitset-mismatched waiters at the start of the queue, then the check
> will early out and the PI mixup will not be discovered until the second walk.
Yes, but that has been the case forever and it's done opportunisticly to
avoid full hash bucket walks wherever possible.
Thanks,
tglx
next prev parent reply other threads:[~2026-07-31 10:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 3:26 [PATCH] futex: Prevent robust futex exit race more Keno Fischer
2026-07-21 12:24 ` Thomas Gleixner
2026-07-21 16:50 ` Keno Fischer
2026-07-22 14:21 ` Thomas Gleixner
2026-07-23 12:53 ` Christian Brauner
2026-07-23 13:24 ` Florian Weimer
2026-07-24 8:20 ` Christian Brauner
2026-07-23 19:59 ` Keno Fischer
2026-07-23 19:44 ` Keno Fischer
2026-07-26 20:39 ` Thomas Gleixner
2026-07-26 22:54 ` Keno Fischer
2026-07-27 13:12 ` Thomas Gleixner
2026-07-27 17:23 ` Keno Fischer
2026-07-28 19:43 ` Thomas Gleixner
2026-07-28 21:29 ` Thomas Gleixner
2026-07-30 21:06 ` Thomas Gleixner
2026-07-30 22:15 ` [PATCH] futex: Make FUTEX_WAITERS state consistent for robust futex unlock Thomas Gleixner
2026-07-31 4:36 ` Keno Fischer
2026-07-31 10:41 ` Thomas Gleixner [this message]
2026-07-31 16:05 ` Thomas Gleixner
2026-07-28 22:05 ` [PATCH] futex: Prevent robust futex exit race more Thomas Gleixner
2026-07-28 22:13 ` Keno Fischer
2026-07-29 13:47 ` Thomas Gleixner
2026-07-29 14:47 ` Keno Fischer
2026-07-30 6:58 ` Thomas Gleixner
2026-07-30 19:46 ` Keno Fischer
2026-07-30 20:39 ` [tip: locking/futex] " tip-bot2 for Keno Fischer
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=87a4r7fnl8.ffs@fw13 \
--to=tglx@kernel.org \
--cc=andrealmeid@igalia.com \
--cc=brauner@kernel.org \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=fweimer@redhat.com \
--cc=keno@juliahub.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=wang.yi59@zte.com.cn \
--cc=yang.tao172@zte.com.cn \
/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