Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/ubsan: remove null-pointer checks

With gcc-8 fsanitize=null become very noisy. GCC started to complain
about things like &a->b, where 'a' is NULL pointer. There is no NULL
dereference, we just calculate address to struct member. It's
technically undefined behavior so UBSAN is correct to report it. But as
long as there is no real NULL-dereference, I think, we should be fine.

-fno-delete-null-pointer-checks compiler flag should protect us from any
consequences. So let's just no use -fsanitize=null as it's not useful
for us. If there is a real NULL-deref we will see crash. Even if
userspace mapped something at NULL (root can do this), with things like
SMAP should catch the issue.

Link: http://lkml.kernel.org/r/20180802153209.813-1-aryabinin@virtuozzo.com
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andrey Ryabinin and committed by
Linus Torvalds
3ca17b1f 5832fcf9

-17
-1
arch/parisc/Kconfig
··· 11 11 select ARCH_HAS_ELF_RANDOMIZE 12 12 select ARCH_HAS_STRICT_KERNEL_RWX 13 13 select ARCH_HAS_UBSAN_SANITIZE_ALL 14 - select ARCH_WANTS_UBSAN_NO_NULL 15 14 select ARCH_SUPPORTS_MEMORY_FAILURE 16 15 select RTC_CLASS 17 16 select RTC_DRV_GENERIC
-1
arch/s390/Kconfig
··· 106 106 select ARCH_USE_BUILTIN_BSWAP 107 107 select ARCH_USE_CMPXCHG_LOCKREF 108 108 select ARCH_WANTS_DYNAMIC_TASK_STRUCT 109 - select ARCH_WANTS_UBSAN_NO_NULL 110 109 select ARCH_WANT_IPC_PARSE_VERSION 111 110 select BUILDTIME_EXTABLE_SORT 112 111 select CLONE_BACKWARDS2
-11
lib/Kconfig.ubsan
··· 1 1 config ARCH_HAS_UBSAN_SANITIZE_ALL 2 2 bool 3 3 4 - config ARCH_WANTS_UBSAN_NO_NULL 5 - def_bool n 6 - 7 4 config UBSAN 8 5 bool "Undefined behaviour sanity checker" 9 6 help ··· 35 38 This option enables detection of unaligned memory accesses. 36 39 Enabling this option on architectures that support unaligned 37 40 accesses may produce a lot of false positives. 38 - 39 - config UBSAN_NULL 40 - bool "Enable checking of null pointers" 41 - depends on UBSAN 42 - default y if !ARCH_WANTS_UBSAN_NO_NULL 43 - help 44 - This option enables detection of memory accesses via a 45 - null pointer. 46 41 47 42 config TEST_UBSAN 48 43 tristate "Module for testing for undefined behavior detection"
-4
scripts/Makefile.ubsan
··· 14 14 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) 15 15 endif 16 16 17 - ifdef CONFIG_UBSAN_NULL 18 - CFLAGS_UBSAN += $(call cc-option, -fsanitize=null) 19 - endif 20 - 21 17 # -fsanitize=* options makes GCC less smart than usual and 22 18 # increase number of 'maybe-uninitialized false-positives 23 19 CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)