Skip to content

Commit 11bb167

Browse files
committed
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Nicolas Schier <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent 056000c commit 11bb167

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

include/linux/compiler-version.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,13 @@
3232
#ifdef RANDSTRUCT
3333
#include <generated/randstruct_hash.h>
3434
#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

scripts/Makefile.ubsan

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ubsan-cflags-$(CONFIG_UBSAN_TRAP) += $(call cc-option,-fsanitize-trap=undefined
1515
export CFLAGS_UBSAN := $(ubsan-cflags-y)
1616

1717
ubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP) += \
18+
-DINTEGER_WRAP \
1819
-fsanitize-undefined-ignore-overflow-pattern=all \
1920
-fsanitize=signed-integer-overflow \
2021
-fsanitize=unsigned-integer-overflow \

scripts/basic/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ cmd_create_randstruct_seed = \
1414
$(obj)/randstruct.seed: $(gen-randstruct-seed) FORCE
1515
$(call if_changed,create_randstruct_seed)
1616
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

0 commit comments

Comments
 (0)