Skip to contentSkip to conversation

ubsan: Disable signed integer overflow sanitizer on GCC < 8

PATCH In review Kees Cook 2 participants 2 messages Mar 13, 2024

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 ubsan: Disable signed integer overflow sanitizer on GCC < 8

For opting functions out of sanitizer coverage, the "no_sanitize" attribute is used, but in GCC this wasn't introduced until GCC 8. Disable the sanitizer unless we're not using GCC, or it is GCC version 8 or higher.

---
Cc: Marco Elver <[email protected]>
Cc: Andrey Konovalov <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 lib/Kconfig.ubsan | 2 ++
 1 file changed, 2 insertions(+)
lib/Kconfig.ubsan +2 -0
index 48a67058f84e..e81e1ac4a919 100644
@@ -119,6 +119,8 @@ config UBSAN_SIGNED_WRAP
 	bool "Perform checking for signed arithmetic wrap-around"
 	default UBSAN
 	depends on !COMPILE_TEST
+	# The no_sanitize attribute was introduced in GCC with version 8.
+	depends on !CC_IS_GCC || GCC_VERSION >= 80000
 	depends on $(cc-option,-fsanitize=signed-integer-overflow)
 	help
 	  This option enables -fsanitize=signed-integer-overflow which checks
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Kees Cook

For opting functions out of sanitizer coverage, the "no_sanitize" attribute is used, but in GCC this wasn't introduced until GCC 8. Disable the sanitizer unless we're not using GCC, or it is GCC version 8 or higher.

Looks reasonable:

Thanks,
-- Marco

Quoted 30 lines

---
Cc: Marco Elver <[email protected]>
Cc: Andrey Konovalov <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 lib/Kconfig.ubsan | 2 ++
 1 file changed, 2 insertions(+)
lib/Kconfig.ubsan +2 -1
index 48a67058f84e..e81e1ac4a919 100644
@@ -119,6 +119,8 @@ config UBSAN_SIGNED_WRAP
        bool "Perform checking for signed arithmetic wrap-around"
        default UBSAN
        depends on !COMPILE_TEST
+       # The no_sanitize attribute was introduced in GCC with version 8.
+       depends on !CC_IS_GCC || GCC_VERSION >= 80000
        depends on $(cc-option,-fsanitize=signed-integer-overflow)
        help
          This option enables -fsanitize=signed-integer-overflow which checks
--

2.34.1

--
You received this message because you are subscribed to the Google Groups "kasan-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20240313181217.work.263-kees%40kernel.org.