[PATCH 1/6] nptl: Treat negative times as timed out in PI futex locking (bug 34543)

Florian Weimer fweimer@redhat.com
Wed Aug 19 19:34:17 GMT 2026


The non-PI case already does this:

  /* Work around the fact that the kernel rejects negative timeout
     values despite them being valid.  */
  if (__glibc_unlikely (abstime->tv_sec < 0))
    return ETIMEDOUT;
---
 nptl/futex-internal.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/nptl/futex-internal.c b/nptl/futex-internal.c
index 07f1462abe..59aef5daf6 100644
--- a/nptl/futex-internal.c
+++ b/nptl/futex-internal.c
@@ -145,6 +145,11 @@ int
 __futex_lock_pi64 (int *futex_word, clockid_t clockid,
 		   const struct __timespec64 *abstime, int private)
 {
+  /* Work around the fact that the kernel rejects negative timeout values
+     despite them being valid.  */
+  if (__glibc_unlikely ((abstime != NULL) && (abstime->tv_sec < 0)))
+    return ETIMEDOUT;
+
   int err;
 
   unsigned int clockbit = clockid == CLOCK_REALTIME

base-commit: a0faa928b094be829c52d1e493442ba3b48954b1
-- 
2.55.0




More information about the Libc-alpha mailing list