From: Thomas Gleixner <tglx@linutronix.de>
To: Wake Liu <wakel@google.com>, Andy Lutomirski <luto@kernel.org>,
Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: linux-kernel@vger.kernel.org, wakel@google.com
Subject: Re: [PATCH] vdso: Define NSEC_PER_SEC as 64-bit to prevent overflow
Date: Wed, 06 Aug 2025 10:55:00 +0200 [thread overview]
Message-ID: <87ikj0esnv.ffs@tglx> (raw)
In-Reply-To: <20250805162153.952693-1-wakel@google.com>
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
next prev parent reply other threads:[~2025-08-06 8:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 16:21 [PATCH] vdso: Define NSEC_PER_SEC as 64-bit to prevent overflow Wake Liu
2025-08-06 8:44 ` Thomas Gleixner
2025-08-06 8:55 ` Thomas Gleixner [this message]
2025-08-09 9:49 ` Wake Liu
2025-08-10 8:03 ` Thomas Gleixner
2025-08-10 8:28 ` Thomas Weißschuh
2025-09-15 19:19 ` [PATCH v2] selftests/timers: Consolidate and fix 32-bit overflow in timespec_sub Wake Liu
2025-09-21 7:49 ` Thomas Gleixner
2026-01-07 23:19 ` Carlos Llamas
2025-08-06 20:28 ` [PATCH] vdso: Define NSEC_PER_SEC as 64-bit to prevent overflow kernel test robot
2025-08-07 7:37 ` kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2025-08-05 16:20 Wake Liu
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=87ikj0esnv.ffs@tglx \
--to=tglx@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=vincenzo.frascino@arm.com \
--cc=wakel@google.com \
/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