ubsan: allow to disable the null sanitizer
authorChristian Borntraeger <borntraeger@de.ibm.com>
Mon, 12 Sep 2016 12:37:19 +0000 (14:37 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 20 Sep 2016 12:26:08 +0000 (14:26 +0200)
Some architectures use a hardware defined structure at address zero.
Checking for a null pointer will result in many ubsan reports.
Allow users to disable the null sanitizer.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
lib/Kconfig.ubsan
scripts/Makefile.ubsan

index 39494af9a84ac89e6fbbc1f25d9407c70d19e66f..bc6e651df68c31e413552356fd5d67ad32cc11c0 100644 (file)
@@ -1,6 +1,9 @@
 config ARCH_HAS_UBSAN_SANITIZE_ALL
        bool
 
+config ARCH_WANTS_UBSAN_NO_NULL
+       def_bool n
+
 config UBSAN
        bool "Undefined behaviour sanity checker"
        help
@@ -34,3 +37,11 @@ config UBSAN_ALIGNMENT
          This option enables detection of unaligned memory accesses.
          Enabling this option on architectures that support unaligned
          accesses may produce a lot of false positives.
+
+config UBSAN_NULL
+       bool "Enable checking of null pointers"
+       depends on UBSAN
+       default y if !ARCH_WANTS_UBSAN_NO_NULL
+       help
+         This option enables detection of memory accesses via a
+         null pointer.
index 8ab68679cfb5b65cebd5f05d5d5054812bd4c651..dd779c40c8e6af713c0ad7039bc929b0c6c2944a 100644 (file)
@@ -3,7 +3,6 @@ ifdef CONFIG_UBSAN
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero)
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable)
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=vla-bound)
-      CFLAGS_UBSAN += $(call cc-option, -fsanitize=null)
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
@@ -14,4 +13,8 @@ ifdef CONFIG_UBSAN
 ifdef CONFIG_UBSAN_ALIGNMENT
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
 endif
+
+ifdef CONFIG_UBSAN_NULL
+      CFLAGS_UBSAN += $(call cc-option, -fsanitize=null)
+endif
 endif