]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Fix __futex_abstimed_wait_cancellable32
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 28 Sep 2020 19:05:32 +0000 (16:05 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 28 Sep 2020 19:05:32 +0000 (16:05 -0300)
Similar to 64-bit time __futex_abstimed_wait_cancellable64, it should
check for overflow and convert to 32-bit timespec iff timeout is not
NULL.

It fixes some regression on i686-linux-gnu running on a 4.15 kernel.

sysdeps/nptl/futex-internal.c

index adb3c20611487473ef3ba0d87f3d5d75a588c886..1594cb6166457ae4619495d0995877111c8e5ce7 100644 (file)
@@ -29,16 +29,22 @@ __futex_abstimed_wait_cancellable32 (unsigned int* futex_word,
                                      const struct __timespec64* abstime,
                                      int private)
 {
-  if (! in_time_t_range (abstime->tv_sec))
-    return -EOVERFLOW;
+  struct timespec ts32, *pts32 = NULL;
+  if (abstime != NULL)
+    {
+      if (! in_time_t_range (abstime->tv_sec))
+       return -EOVERFLOW;
+
+      ts32 = valid_timespec64_to_timespec (*abstime);
+      pts32 = &ts32;
+    }
 
   unsigned int clockbit = (clockid == CLOCK_REALTIME)
          ? FUTEX_CLOCK_REALTIME : 0;
   int op = __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, private);
 
-  struct timespec ts32 = valid_timespec64_to_timespec (*abstime);
   return INTERNAL_SYSCALL_CANCEL (futex, futex_word, op, expected,
-                                  &ts32, NULL /* Unused.  */,
+                                  pts32, NULL /* Unused.  */,
                                   FUTEX_BITSET_MATCH_ANY);
 }
 #endif