arm64: uapi: Provide correct __BITS_PER_LONG for the compat vDSO
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Thu, 21 Aug 2025 07:56:44 +0000 (09:56 +0200)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 3 Sep 2025 11:07:23 +0000 (12:07 +0100)
commit9a6d3ff10f7f538835cae4799562004ee46922c5
tree0c5d7895dfe33e4f99c9b4b4cad3f622bf2bd53a
parentd82aa5d3501b25bfb7bc2a24a68ad0a83b2ad10b
arm64: uapi: Provide correct __BITS_PER_LONG for the compat vDSO

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@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@linutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/r/20250821-vdso-arm64-compat-bitsperlong-v1-1-700bcabe7732@linutronix.de
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/uapi/asm/bitsperlong.h