Skip to content

Commit ebd6679

Browse files
t-8chSasha Levin
authored andcommitted
uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again
commit 11fcf36 upstream. Commit 1e7933a ("uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)"") did not take in account that the usage of BITS_PER_LONG in __GENMASK() was changed to __BITS_PER_LONG for UAPI-safety in commit 3c7a8e1 ("uapi: introduce uapi-friendly macros for GENMASK"). BITS_PER_LONG can not be used in UAPI headers as it derives from the kernel configuration and not from the current compiler invocation. When building compat userspace code or a compat vDSO its value will be incorrect. Switch back to __BITS_PER_LONG. Fixes: 1e7933a ("uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)"") Cc: [email protected] Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Yury Norov [NVIDIA] <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1ad4bd3 commit ebd6679

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/uapi/linux/bits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#ifndef _UAPI_LINUX_BITS_H
55
#define _UAPI_LINUX_BITS_H
66

7-
#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))
7+
#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))
88

9-
#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
9+
#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
1010

1111
#define __GENMASK_U128(h, l) \
1212
((_BIT128((h)) << 1) - (_BIT128(l)))

0 commit comments

Comments
 (0)