The patch titled Subject: compiler-attributes-add-__alloc_size-for-better-bounds-checking-fix-fix has been removed from the -mm tree. Its filename was compiler-attributes-add-__alloc_size-for-better-bounds-checking-fix-fix.patch This patch was dropped because an alternative patch was merged ------------------------------------------------------ From: Kees Cook <keescook@xxxxxxxxxxxx> Subject: compiler-attributes-add-__alloc_size-for-better-bounds-checking-fix-fix Okay, I think this work-around should work. I've been able to reproduce the weird conditions, and this seems to behave correctly. Andrew, can you fixup the fixup with this? Link: https://lkml.kernel.org/r/202108250959.CD734CED@keescook Reported-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx> Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/Makefile~compiler-attributes-add-__alloc_size-for-better-bounds-checking-fix-fix +++ a/Makefile @@ -1096,8 +1096,13 @@ endif ifdef CONFIG_CC_IS_GCC # The allocators already balk at large sizes, so silence the compiler -# warnings for bounds checks involving those possible values. -KBUILD_CFLAGS += $(call cc-option, -Wno-alloc-size-larger-than) +# warnings for bounds checks involving those possible values. While +# -Wno-alloc-size-larger-than would normally be used here, some versions +# of gcc (<9.1) weirdly don't handle the option correctly when _other_ +# warnings are produced (?!), so instead use SIZE_MAX to effectively +# disable it. +# https://lore.kernel.org/lkml/20210824115859.187f272f@xxxxxxxxxxxxxxxx +KBUILD_CFLAGS += $(call cc-option, -Walloc-size-larger-than=SIZE_MAX) endif # disable invalid "can't wrap" optimizations for signed / pointers _ Patches currently in -mm which might be from keescook@xxxxxxxxxxxx are compiler-attributes-add-__alloc_size-for-better-bounds-checking.patch compiler-attributes-add-__alloc_size-for-better-bounds-checking-fix-2.patch checkpatch-add-__alloc_size-to-known-attribute.patch slab-clean-up-function-declarations.patch slab-add-__alloc_size-attributes-for-better-bounds-checking.patch mm-page_alloc-add-__alloc_size-attributes-for-better-bounds-checking.patch percpu-add-__alloc_size-attributes-for-better-bounds-checking.patch mm-vmalloc-add-__alloc_size-attributes-for-better-bounds-checking.patch