Re: arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:308 __cvdso_clock_gettime_common() warn: right shifting more than type allows 32 vs 40

From: Thomas Weißschuh

Date: Wed Feb 11 2026 - 07:29:15 EST


On Wed, Feb 11, 2026 at 03:13:34PM +0300, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 192c0159402e6bfbe13de6f8379546943297783d
> commit: 693c819fedcdcabfda7488e2d5e355a84c2fd1b0 x86/entry/vdso: Refactor the vdso build
> config: x86_64-randconfig-161-20260210 (https://download.01.org/0day-ci/archive/20260211/202602111941.PIhubgrb-lkp@xxxxxxxxx/config)
> compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
> smatch version: v0.5.0-8994-gd50c5a4c
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202602111941.PIhubgrb-lkp@xxxxxxxxx/
>
> smatch warnings:
> arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:308 __cvdso_clock_gettime_common() warn: right shifting more than type allows 32 vs 40
> arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:308 __cvdso_clock_gettime_common() warn: bitwise AND condition is false here
> arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:454 __cvdso_clock_getres_common() warn: right shifting more than type allows 32 vs 40
> arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:454 __cvdso_clock_getres_common() warn: bitwise AND condition is false here

Thanks for the report!

> vim +308 arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c
>
> fb61bdb27fd730 Thomas Weißschuh 2025-07-01 287 static __always_inline bool
> ac1a42f4e4e296 Thomas Weißschuh 2025-02-04 288 __cvdso_clock_gettime_common(const struct vdso_time_data *vd, clockid_t clock,
> e876f0b69dc993 Christophe Leroy 2020-02-07 289 struct __kernel_timespec *ts)
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 290 {
> 886653e3663917 Anna-Maria Behnsen 2025-03-03 291 const struct vdso_clock *vc = vd->clock_data;
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 292 u32 msk;
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 293
> 1a1cd5fe881fdf Thomas Weißschuh 2025-07-01 294 if (!vdso_clockid_valid(clock))
> fb61bdb27fd730 Thomas Weißschuh 2025-07-01 295 return false;
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 296
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 297 /*
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 298 * Convert the clockid to a bitmask and use it to check which
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 299 * clocks are handled in the VDSO directly.
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 300 */
> 00b26474c2f161 Vincenzo Frascino 2019-06-21 301 msk = 1U << clock;
> 8463cf80529d0f Christophe Leroy 2019-12-23 302 if (likely(msk & VDSO_HRES))
> cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03 303 vc = &vc[CS_HRES_COARSE];
> 8463cf80529d0f Christophe Leroy 2019-12-23 304 else if (msk & VDSO_COARSE)
> 70067ae181f302 Anna-Maria Behnsen 2025-03-03 305 return do_coarse(vd, &vc[CS_HRES_COARSE], clock, ts);
> 8463cf80529d0f Christophe Leroy 2019-12-23 306 else if (msk & VDSO_RAW)
> cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03 307 vc = &vc[CS_RAW];
> cd3557a7618bf5 Thomas Weißschuh 2025-07-01 @308 else if (msk & VDSO_AUX)
>
> This code is built with -m32 when we build
> arch/x86/entry/vdso/vdso32/vclock_gettime.c so VDSO_AUX is zero
> and we never call do_aux(). Presumably that's intentional. I
> don't know this code at all.

This is a false positive due to a mismatch between compiler and $(CHECK) flags.
We are working on a fix, see:
* https://lore.kernel.org/lkml/20260116-vdso-compat-checkflags-v1-2-4a83b4fbb0d3@xxxxxxxxxxxxx/
* https://lore.kernel.org/lkml/20260117215542.342638347@xxxxxxxxxx/

> cd3557a7618bf5 Thomas Weißschuh 2025-07-01 309 return do_aux(vd, clock, ts);
> c966533f8c6c45 Andrei Vagin 2019-11-12 310 else
> fb61bdb27fd730 Thomas Weißschuh 2025-07-01 311 return false;
> c966533f8c6c45 Andrei Vagin 2019-11-12 312
> 64c3613ce31a1a Anna-Maria Behnsen 2025-03-03 313 return do_hres(vd, vc, clock, ts);
> 502a590a170b3b Thomas Gleixner 2019-07-28 314 }
>