]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ubsan/overflow: Enable ignorelist parsing and add type filter
authorKees Cook <kees@kernel.org>
Fri, 7 Mar 2025 04:19:11 +0000 (20:19 -0800)
committerKees Cook <kees@kernel.org>
Sat, 8 Mar 2025 03:58:05 +0000 (19:58 -0800)
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 <justinstitt@google.com>
Link: https://lore.kernel.org/r/20250307041914.937329-3-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
lib/Kconfig.ubsan
scripts/Makefile.ubsan
scripts/integer-wrap-ignore.scl [new file with mode: 0644]

index 888c2e72c586e001c65f80e15bacefe5d87f8e4c..4216b3a4ff218fc50b5ca0a41be276b1ded55930 100644 (file)
@@ -125,6 +125,7 @@ config UBSAN_INTEGER_WRAP
        depends on $(cc-option,-fsanitize=unsigned-integer-overflow)
        depends on $(cc-option,-fsanitize=implicit-signed-integer-truncation)
        depends on $(cc-option,-fsanitize=implicit-unsigned-integer-truncation)
+       depends on $(cc-option,-fsanitize-ignorelist=/dev/null)
        help
          This option enables all of the sanitizers involved in integer overflow
          (wrap-around) mitigation: signed-integer-overflow, unsigned-integer-overflow,
index 233379c193a75433b7d380ec96160168e18a81e0..9e35198edbf0d08d7b281cd43d882046a84e4e37 100644 (file)
@@ -19,5 +19,6 @@ ubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP)     += \
        -fsanitize=signed-integer-overflow                      \
        -fsanitize=unsigned-integer-overflow                    \
        -fsanitize=implicit-signed-integer-truncation           \
-       -fsanitize=implicit-unsigned-integer-truncation
+       -fsanitize=implicit-unsigned-integer-truncation         \
+       -fsanitize-ignorelist=$(srctree)/scripts/integer-wrap-ignore.scl
 export CFLAGS_UBSAN_INTEGER_WRAP := $(ubsan-integer-wrap-cflags-y)
diff --git a/scripts/integer-wrap-ignore.scl b/scripts/integer-wrap-ignore.scl
new file mode 100644 (file)
index 0000000..431c305
--- /dev/null
@@ -0,0 +1,3 @@
+[{unsigned-integer-overflow,signed-integer-overflow,implicit-signed-integer-truncation,implicit-unsigned-integer-truncation}]
+type:*
+type:size_t=sanitize