The patch titled Subject: bitops: avoid integer overflow in GENMASK(_ULL) has been added to the -mm tree. Its filename is bitops-avoid-integer-overflow-in-genmask_ull.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/bitops-avoid-integer-overflow-in-genmask_ull.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/bitops-avoid-integer-overflow-in-genmask_ull.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Matthias Kaehlcke <mka@xxxxxxxxxxxx> Subject: bitops: avoid integer overflow in GENMASK(_ULL) GENMASK(_ULL) performs a left-shift of ~0UL(L), which technically results in an integer overflow. clang raises a warning if the overflow occurs in a preprocessor expression. Clear the low-order bits through a substraction instead of the left-shift to avoid the overflow. (akpm: no change in .text size in my testing) Link: http://lkml.kernel.org/r/20170803212020.24939-1-mka@xxxxxxxxxxxx Signed-off-by: Matthias Kaehlcke <mka@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/bitops.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff -puN include/linux/bitops.h~bitops-avoid-integer-overflow-in-genmask_ull include/linux/bitops.h --- a/include/linux/bitops.h~bitops-avoid-integer-overflow-in-genmask_ull +++ a/include/linux/bitops.h @@ -19,10 +19,11 @@ * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. */ #define GENMASK(h, l) \ - (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) #define GENMASK_ULL(h, l) \ - (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + (((~0ULL) - (1ULL << (l)) + 1) & \ + (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) extern unsigned int __sw_hweight8(unsigned int w); extern unsigned int __sw_hweight16(unsigned int w); _ Patches currently in -mm which might be from mka@xxxxxxxxxxxx are mm-memcontrol-use-int-for-event-state-parameter-in-several-functions.patch mm-memcontrol-use-int-for-event-state-parameter-in-several-functions-v2.patch bitops-avoid-integer-overflow-in-genmask_ull.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html