[PATCH 1/3] arm64: uapi: Provide correct __BITS_PER_LONG for the compat vDSO

Arnd Bergmann arnd at arndb.de
Thu Aug 21 10:33:24 PDT 2025


On Thu, Aug 21, 2025, at 09:56, Thomas Weißschuh wrote:
> The generic vDSO library uses the UAPI headers. On arm64 __BITS_PER_LONG is
> always '64' even when used from the compat vDSO. In that case __GENMASK()
> does an illegal bitshift, invoking undefined behaviour.
>
> Change __BITS_PER_LONG to also work when used from the comapt vDSO.
> To not confuse real userspace, only do this when building the kernel.
>
> Reported-by: John Stultz <jstultz at google.com>
> Closes: 
> https://lore.kernel.org/lkml/CANDhNCqvKOc9JgphQwr0eDyJiyG4oLFS9R8rSFvU0fpurrJFDg@mail.gmail.com/
> Fixes: cd3557a7618b ("vdso/gettimeofday: Add support for auxiliary 
> clocks")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>

Acked-by: Arnd Bergmann <arnd at arndb.de>

> +#if defined(__KERNEL__) && !defined(__aarch64__)
> +/* Used by the compat vDSO */
> +#define __BITS_PER_LONG 32
> +#else
>  #define __BITS_PER_LONG 64
> +#endif

This should be fine as a hotfix, but I'm worried about this
coming back since there is not enough isolation between
uapi/asm/ headers and the vdso. We've had problems here
before, and arm64 more likely to be affected here than others
because the asm/ headers are not meant to be included from
32-bit compilation units.

A better approach might be either to build the arm64 compat vdso
against the arm32 headers, or to change the vdso code enough
that it only needs headers from the vdso namespace and not
include the uapi/asm/ namespace at all.

Unfortunately both of those require a substantial amount of
work, and are not an option for the current release.

     Arnd



More information about the linux-arm-kernel mailing list