Re: [PATCH] futex: Prevent robust futex exit race more

From: Keno Fischer

Date: Thu Jul 23 2026 - 16:01:39 EST


On Thu, Jul 23, 2026 at 8:53 AM Christian Brauner <brauner@xxxxxxxxxx> wrote:
> On Wed, Jul 22, 2026 at 04:21:12PM +0200, Thomas Gleixner wrote:
> > Unsurprisingly a robust futex depends on unique PIDs, which are not
> > obviously not guaranteed accross multiple PID namespaces.
>
> Fwiw, I added unique inode numbers for the lifetime of the system to
> pidfds some time ago. The inode number is allocated for every struct pid
> and available via pid->ino. A pidfd can be stat()ed to retrieve it. Just
> mentioning it in case this may be useful.

They have the correct property of being unique cookies but they don't
(currently) fit in a 32-bit futex word. And if we ever get 64-bit futex words,
I think userspace could just mint cookies themselves per-operation. That
said, perhaps they could be useful for the PI case, although that's much
trickier and I'm much less convinced that cross-pid-namespace PI futexes
are useful or desirable. It is a bit awkward in that all threads do already have
systemwide unique ids in the root pid namespace, but whether or not they
can read them depends on whether they have access to a `/proc` that was
mounted by the original pid namespace. That's why I was sort of hoping to
get the kernel out of the business on interpreting the value of the futex cookie
in the non-PI case and let userspace figure out where to get a unique id
depending on the circumstances and isolation requirements.