lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260114095140-f66083c0-54e3-46f9-8f0e-d1a526028236@linutronix.de>
Date: Wed, 14 Jan 2026 09:56:46 +0100
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Sun Jian <sun.jian.kdev@...il.com>
Cc: Andy Lutomirski <luto@...nel.org>, Thomas Gleixner <tglx@...nel.org>, 
	Vincenzo Frascino <vincenzo.frascino@....com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib/vdso: guard clockid before building u32 bitmask

On Wed, Jan 14, 2026 at 04:45:29PM +0800, Sun Jian wrote:
> __cvdso_clock_gettime_common() and __cvdso_clock_getres_common() build a
> u32 bitmask from clockid_t using "1U << clock". This requires the shift
> amount to be < 32, otherwise leading to undefined behaviour.
> 
> Add a guard to reject out-of-range clockids before building the bitmask.
> This avoids undefined shifts and silences sparse "shift too big" warnings.
> 
> No functional change intended.
> 
> Signed-off-by: Sun Jian <sun.jian.kdev@...il.com>
> ---
>  lib/vdso/gettimeofday.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
> index 95df0153f05a..eee30f2bc6c6 100644
> --- a/lib/vdso/gettimeofday.c
> +++ b/lib/vdso/gettimeofday.c
> @@ -298,6 +298,9 @@ __cvdso_clock_gettime_common(const struct vdso_time_data *vd, clockid_t clock,
>  	 * Convert the clockid to a bitmask and use it to check which
>  	 * clocks are handled in the VDSO directly.
>  	 */
> +	if ((u32)clock >= 32)
> +		return false;

Right above is this check:

if (!vdso_clockid_valid(clock))
	return false;


where:

static __always_inline bool vdso_clockid_valid(clockid_t clock)
{
	/* Check for negative values or invalid clocks */
	/* CLOCK_AUX_LAST == 23 */
	return likely((u32) clock <= CLOCK_AUX_LAST);
}


So this looks like a false-positive. Can you post the sparse warning?


Thomas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ