public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: [COMMITTED] nptl: Fix __futex_abstimed_wait_cancellable32
Date: Mon, 28 Sep 2020 16:18:31 -0300	[thread overview]
Message-ID: <20200928191831.1324596-1-adhemerval.zanella@linaro.org> (raw)

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 | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sysdeps/nptl/futex-internal.c b/sysdeps/nptl/futex-internal.c
index adb3c20611..1594cb6166 100644
--- a/sysdeps/nptl/futex-internal.c
+++ b/sysdeps/nptl/futex-internal.c
@@ -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
-- 
2.25.1


                 reply	other threads:[~2020-09-28 19:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200928191831.1324596-1-adhemerval.zanella@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).