[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANDhNCoiKjPOyGwiu5Apg2y4LduPTRQvEjG7snmbzrenZojAKg@mail.gmail.com>
Date: Tue, 3 Jun 2025 13:27:04 -0700
From: John Stultz <jstultz@...gle.com>
To: Terry Tritton <terry.tritton@...aro.org>
Cc: Thomas Gleixner <tglx@...utronix.de>, Stephen Boyd <sboyd@...nel.org>, Shuah Khan <shuah@...nel.org>,
ttritton@...gle.com, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests/timers: Fix integer overlow errors on 32 bit systems
On Tue, Jun 3, 2025 at 1:10 PM Terry Tritton <terry.tritton@...aro.org> wrote:
>
> The use of NSEC_PER_SEC (1000000000L) as defined in include/vdso/time64.h
> causes several integer overflow warnings and test errors on 32 bit
> architectures.
>
> Use a long long instead of long to prevent integer overflow when
> converting seconds to nanoseconds.
>
> Signed-off-by: Terry Tritton <terry.tritton@...aro.org>
Needs a Fixes: tag?
> ---
> tools/testing/selftests/timers/adjtick.c | 5 ++++-
> tools/testing/selftests/timers/alarmtimer-suspend.c | 4 +++-
> tools/testing/selftests/timers/inconsistency-check.c | 4 +++-
> tools/testing/selftests/timers/leap-a-day.c | 4 +++-
> tools/testing/selftests/timers/mqueue-lat.c | 3 ++-
> tools/testing/selftests/timers/nanosleep.c | 4 +++-
> tools/testing/selftests/timers/nsleep-lat.c | 4 +++-
> tools/testing/selftests/timers/posix_timers.c | 5 ++++-
> tools/testing/selftests/timers/raw_skew.c | 4 +++-
> tools/testing/selftests/timers/set-2038.c | 4 +++-
> tools/testing/selftests/timers/set-timer-lat.c | 4 +++-
> tools/testing/selftests/timers/valid-adjtimex.c | 5 ++++-
> 12 files changed, 38 insertions(+), 12 deletions(-)
>
> diff --git a/tools/testing/selftests/timers/adjtick.c b/tools/testing/selftests/timers/adjtick.c
> index 777d9494b683..b5929c33b632 100644
> --- a/tools/testing/selftests/timers/adjtick.c
> +++ b/tools/testing/selftests/timers/adjtick.c
> @@ -22,10 +22,13 @@
> #include <sys/time.h>
> #include <sys/timex.h>
> #include <time.h>
> -#include <include/vdso/time64.h>
>
> #include "../kselftest.h"
>
> +/* define NSEC_PER_SEC as long long to avoid overflow on 32 bit architectures*/
> +#define NSEC_PER_SEC 1000000000LL
> +#define USEC_PER_SEC 1000000LL
> +
> #define MILLION 1000000
>
> long systick;
> diff --git a/tools/testing/selftests/timers/alarmtimer-suspend.c b/tools/testing/selftests/timers/alarmtimer-suspend.c
> index a9ef76ea6051..b5799df271ae 100644
> --- a/tools/testing/selftests/timers/alarmtimer-suspend.c
> +++ b/tools/testing/selftests/timers/alarmtimer-suspend.c
> @@ -28,10 +28,12 @@
> #include <signal.h>
> #include <stdlib.h>
> #include <pthread.h>
> -#include <include/vdso/time64.h>
> #include <errno.h>
> #include "../kselftest.h"
>
> +/* define NSEC_PER_SEC as long long to avoid overflow on 32 bit architectures*/
> +#define NSEC_PER_SEC 1000000000LL
> +
> #define UNREASONABLE_LAT (NSEC_PER_SEC * 5) /* hopefully we resume in 5 secs */
So this seems to be undoing commit 80fa614e2fbc ("selftests: timers:
Remove local NSEC_PER_SEC and USEC_PER_SEC defines")
Would it make more sense to fix the NSEC_PER_SEC definition in time64.h to a LL?
thanks
-john
Powered by blists - more mailing lists