History

ubsan: allow to disable the null sanitizer

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.

Christian Borntraeger committed 10 years ago

Commit 725c4d21 parent f2961902 files · +15 −1Browse files

Unified · Split

2 files
  1. lib/Kconfig.ubsan +11 −0
  2. scripts/Makefile.ubsan +4 −1
lib/Kconfig.ubsan+11−0
@@ -1,6 +1,9 @@
1config ARCH_HAS_UBSAN_SANITIZE_ALL1config ARCH_HAS_UBSAN_SANITIZE_ALL
2 bool2 bool
3 3
4config ARCH_WANTS_UBSAN_NO_NULL
5 def_bool n
6
4config UBSAN7config UBSAN
5 bool "Undefined behaviour sanity checker"8 bool "Undefined behaviour sanity checker"
6 help9 help
@@ -34,3 +37,11 @@ config UBSAN_ALIGNMENT · 27 unmodified lines
34 This option enables detection of unaligned memory accesses.37 This option enables detection of unaligned memory accesses.
35 Enabling this option on architectures that support unaligned38 Enabling this option on architectures that support unaligned
36 accesses may produce a lot of false positives.39 accesses may produce a lot of false positives.
40
41config UBSAN_NULL
42 bool "Enable checking of null pointers"
43 depends on UBSAN
44 default y if !ARCH_WANTS_UBSAN_NO_NULL
45 help
46 This option enables detection of memory accesses via a
47 null pointer.
scripts/Makefile.ubsan+4−1
@@ -3,7 +3,6 @@ ifdef CONFIG_UBSAN · 2 unmodified lines
3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero)3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero)
4 CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable)4 CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable)
5 CFLAGS_UBSAN += $(call cc-option, -fsanitize=vla-bound)5 CFLAGS_UBSAN += $(call cc-option, -fsanitize=vla-bound)
6 CFLAGS_UBSAN += $(call cc-option, -fsanitize=null)
7 CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)6 CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
8 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)7 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
9 CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)8 CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
@@ -14,4 +13,8 @@ ifdef CONFIG_UBSAN · 4 unmodified lines
14ifdef CONFIG_UBSAN_ALIGNMENT13ifdef CONFIG_UBSAN_ALIGNMENT
15 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)14 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
16endif15endif
16
17ifdef CONFIG_UBSAN_NULL
18 CFLAGS_UBSAN += $(call cc-option, -fsanitize=null)
19endif
17endif20endif