All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] futex_wake04: avoid tst_ts_from_ns overflow on 32-bit platforms
Date: Tue,  8 Jun 2021 10:27:23 -0300	[thread overview]
Message-ID: <20210608132723.255996-1-cascardo@canonical.com> (raw)

When multiplying 30 with NSEC_PER_SEC, the result would overflow on 32-bit
platforms, unless cast to long long, which is what tst_ts_from_ns expects.

Though we could change NSEC_PER_SEC to be a long long constant, it was
considered a risk for regressions, as it would affect every use of it.

After this change, futex_wake04 passes on i386.

Reported-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
---
 testcases/kernel/syscalls/futex/futex_wake04.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/futex/futex_wake04.c b/testcases/kernel/syscalls/futex/futex_wake04.c
index 2260a3936d6e..479001e2e59a 100644
--- a/testcases/kernel/syscalls/futex/futex_wake04.c
+++ b/testcases/kernel/syscalls/futex/futex_wake04.c
@@ -56,7 +56,7 @@ static void setup(void)
 	tst_res(TINFO, "Testing variant: %s", tv->desc);
 	futex_supported_by_kernel(tv->fntype);
 
-	to = tst_ts_from_ns(tv->tstype, 30 * NSEC_PER_SEC);
+	to = tst_ts_from_ns(tv->tstype, (long long) 30 * NSEC_PER_SEC);
 }
 
 static void *wait_thread1(void *arg LTP_ATTRIBUTE_UNUSED)
-- 
2.30.2


             reply	other threads:[~2021-06-08 13:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 13:27 Thadeu Lima de Souza Cascardo [this message]
2021-06-09  8:23 ` [LTP] [PATCH] futex_wake04: avoid tst_ts_from_ns overflow on 32-bit platforms Cyril Hrubis
2021-06-09 11:20   ` Thadeu Lima de Souza Cascardo
2021-06-09 13:38     ` Cyril Hrubis
2021-06-09 14:22       ` Thadeu Lima de Souza Cascardo
2021-06-09 14:09         ` Cyril Hrubis

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=20210608132723.255996-1-cascardo@canonical.com \
    --to=cascardo@canonical.com \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.