Skip to content

Commit 47f4af4

Browse files
committed
ubsan/overflow: Enable ignorelist parsing and add type filter
Limit integer wrap-around mitigation to only the "size_t" type (for now). Notably this covers all special functions/builtins that return "size_t", like sizeof(). This remains an experimental feature and is likely to be replaced with type annotations. Reviewed-by: Justin Stitt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 272a767 commit 47f4af4

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/Kconfig.ubsan

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ config UBSAN_INTEGER_WRAP
125125
depends on $(cc-option,-fsanitize=unsigned-integer-overflow)
126126
depends on $(cc-option,-fsanitize=implicit-signed-integer-truncation)
127127
depends on $(cc-option,-fsanitize=implicit-unsigned-integer-truncation)
128+
depends on $(cc-option,-fsanitize-ignorelist=/dev/null)
128129
help
129130
This option enables all of the sanitizers involved in integer overflow
130131
(wrap-around) mitigation: signed-integer-overflow, unsigned-integer-overflow,

scripts/Makefile.ubsan

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ ubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP) += \
1919
-fsanitize=signed-integer-overflow \
2020
-fsanitize=unsigned-integer-overflow \
2121
-fsanitize=implicit-signed-integer-truncation \
22-
-fsanitize=implicit-unsigned-integer-truncation
22+
-fsanitize=implicit-unsigned-integer-truncation \
23+
-fsanitize-ignorelist=$(srctree)/scripts/integer-wrap-ignore.scl
2324
export CFLAGS_UBSAN_INTEGER_WRAP := $(ubsan-integer-wrap-cflags-y)

scripts/integer-wrap-ignore.scl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{unsigned-integer-overflow,signed-integer-overflow,implicit-signed-integer-truncation,implicit-unsigned-integer-truncation}]
2+
type:*
3+
type:size_t=sanitize

0 commit comments

Comments
 (0)