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

Florian Weimer <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <362bb8f503cfff5b6c0f28c9dbafefea459be3c9.1787168028.git.fweimer@redhat.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.