Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

integer-wrap: Force full rebuild when .scl file changes

Since the integer wrapping sanitizer's behavior depends on its associated
.scl file, we must force a full rebuild if the file changes. If not,
instrumentation may differ between targets based on when they were built.

Generate a new header file, integer-wrap.h, any time the Clang .scl
file changes. Include the header file in compiler-version.h when its
associated feature name, INTEGER_WRAP, is defined. This will be picked
up by fixdep and force rebuilds where needed.

Acked-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20250503184623.2572355-3-kees@kernel.org
Reviewed-by: Nicolas Schier <n.schier@avm.de>
Signed-off-by: Kees Cook <kees@kernel.org>

Kees Cook 11bb1678 056000c4

+16
+10
include/linux/compiler-version.h
··· 32 32 #ifdef RANDSTRUCT 33 33 #include <generated/randstruct_hash.h> 34 34 #endif 35 + 36 + /* 37 + * If any external changes affect Clang's integer wrapping sanitizer 38 + * behavior, a full rebuild is needed as the coverage for wrapping types 39 + * may have changed, which may impact the expected behaviors that should 40 + * not differ between compilation units. 41 + */ 42 + #ifdef INTEGER_WRAP 43 + #include <generated/integer-wrap.h> 44 + #endif
+1
scripts/Makefile.ubsan
··· 15 15 export CFLAGS_UBSAN := $(ubsan-cflags-y) 16 16 17 17 ubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP) += \ 18 + -DINTEGER_WRAP \ 18 19 -fsanitize-undefined-ignore-overflow-pattern=all \ 19 20 -fsanitize=signed-integer-overflow \ 20 21 -fsanitize=unsigned-integer-overflow \
+5
scripts/basic/Makefile
··· 14 14 $(obj)/randstruct.seed: $(gen-randstruct-seed) FORCE 15 15 $(call if_changed,create_randstruct_seed) 16 16 always-$(CONFIG_RANDSTRUCT) += randstruct.seed 17 + 18 + # integer-wrap: if the .scl file changes, we need to do a full rebuild. 19 + $(obj)/../../include/generated/integer-wrap.h: $(srctree)/scripts/integer-wrap-ignore.scl FORCE 20 + $(call if_changed,touch) 21 + always-$(CONFIG_UBSAN_INTEGER_WRAP) += ../../include/generated/integer-wrap.h