mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Robust mutex ABI problem (kernel docs regression)
@ 2024-01-11 16:46 Rich Felker
  2024-01-11 16:59 ` [musl] " Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Felker @ 2024-01-11 16:46 UTC (permalink / raw)
  To: libc-alpha, musl, linux-api

It came to my attention while reviewing some proposals for additional
error checking in musl libc that the kernel folks introduced a quiet
regression in the futex ABI for robust mutexes.

Prior to kernel commit 9c40365a65d62d7c06a95fb331b3442cb02d2fd9, bit
29 of the futex lock word was reserved, meaning it could never be part
of a TID. This allowed both glibc and musl to use special values like

/* Magic cookie representing robust mutex with dead owner.  */
/* Magic cookie representing not recoverable robust mutex.  */

to represent special states needed for robust mutex consistency
handling, without the risk that, when masked with FUTEX_TID_MASK
(0x3fffffff), they could be equal to the TID of a real task, which
could result in the kernel robustlist-processing mishandling them.

In practice this is only a documentation regression. The real limit on
TIDs is well below that, at something like 22-bit last I checked.
However to be future-proof, and as other systems may implement the
Linux API/ABI (e.g. things like WSL1, FreeBSD Linux syscall layer,
etc.), I believe it's important that the documented interface be
compatible with the way it actually needs to be used here. This means
either bit 29 should have its reserved status restored, or there
should be a guarantee that the values 0x3fffffff and 0x3ffffffe are
reserved and compare not-equal to any actual TID.

Depending on how folks want to proceed with this, I can propose a
patch to the documentation, or leave that to others.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-11 16:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11 16:46 [musl] Robust mutex ABI problem (kernel docs regression) Rich Felker
2024-01-11 16:59 ` [musl] " Rich Felker

Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).