Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1481216

[PATCH 1/2] ubsan: allow to disable the null sanitizer

From Christian Borntraeger <borntraeger@de.ibm.com>
Newsgroups linux.kernel
Subject [PATCH 1/2] ubsan: allow to disable the null sanitizer
Date 2016-09-12 14:40 +0200
Message-ID <sgyGK-3jx-41@gated-at.bofh.it> (permalink)
References <sgyGK-3jx-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Some architectures use a hardware defined struct at address zero.
Checking for a null pointer will result in many ubsan reports.
Let users disable the null sanitizer.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 lib/Kconfig.ubsan      | 11 +++++++++++
 scripts/Makefile.ubsan |  5 ++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan
index 39494af..851c3f2 100644
--- a/lib/Kconfig.ubsan
+++ b/lib/Kconfig.ubsan
@@ -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 UBSAN && !ARCH_WANTS_UBSAN_NO_NULL
+	help
+	  This option enables detection of memory accesses via a
+	  null pointer.
diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan
index 77ce538..3b1b138 100644
--- a/scripts/Makefile.ubsan
+++ b/scripts/Makefile.ubsan
@@ -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)
@@ -15,6 +14,10 @@ ifdef CONFIG_UBSAN_ALIGNMENT
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
 endif
 
+ifdef CONFIG_UBSAN_NULL
+      CFLAGS_UBSAN += $(call cc-option, -fsanitize=null)
+endif
+
       # -fsanitize=* options makes GCC less smart than usual and
       # increase number of 'maybe-uninitialized false-positives
       CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)
-- 
2.5.5

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] ubsan for s390 Christian Borntraeger <borntraeger@de.ibm.com> - 2016-09-12 14:40 +0200
  [PATCH 2/2] s390/ubsan: enable UBSAN for s390 Christian Borntraeger <borntraeger@de.ibm.com> - 2016-09-12 14:40 +0200
  [PATCH 1/2] ubsan: allow to disable the null sanitizer Christian Borntraeger <borntraeger@de.ibm.com> - 2016-09-12 14:40 +0200
    Re: [PATCH 1/2] ubsan: allow to disable the null sanitizer Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-09-13 08:50 +0200

csiph-web