[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ikj0esnv.ffs@tglx>
Date: Wed, 06 Aug 2025 10:55:00 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Wake Liu <wakel@...gle.com>, Andy Lutomirski <luto@...nel.org>, Vincenzo
Frascino <vincenzo.frascino@....com>
Cc: linux-kernel@...r.kernel.org, wakel@...gle.com
Subject: Re: [PATCH] vdso: Define NSEC_PER_SEC as 64-bit to prevent overflow
On Wed, Aug 06 2025 at 00:21, Wake Liu wrote:
> The constant NSEC_PER_SEC (1,000,000,000) is defined as a long literal.
> On 32-bit systems like arm32, where long is 32 bits, this value can
> overflow when used in 64-bit calculations.
How so? Where is the overflow exactly?
The only usage of NSEC_PER_SEC in the VDSO is:
# git grep NSEC_PER_SEC lib/vdso/
lib/vdso/gettimeofday.c: ts->tv_sec = sec + __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
and __iter_div_u64_rem() is an inline:
static __always_inline u32
__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
So how exactly is this causing an overflow?
Also by your description this would be a problem throughout the kernel.
Thanks,
tglx
Powered by blists - more mailing lists