lib/ubsan: default UBSAN_ALIGNMENT to not set
authorAnders Roxell <anders.roxell@linaro.org>
Fri, 8 Mar 2019 00:30:16 +0000 (16:30 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 8 Mar 2019 02:32:02 +0000 (18:32 -0800)
When booting an allmodconfig kernel, there are a lot of false-positives.
With a message like this 'UBSAN: Undefined behaviour in...' with a call
trace that follows.

UBSAN warnings are a result of enabling noisy CONFIG_UBSAN_ALIGNMENT
which is disabled by default if HAVE_EFFICIENT_UNALIGNED_ACCESS=y.

It's noisy even if don't have efficient unaligned access, e.g.  people
often add __cacheline_aligned_in_smp in structs, but forget to align
allocations of such struct (kmalloc() give 8-byte alignment in worst
case).

Rework so that when building a allmodconfig kernel that turns everything
into '=m' or '=y' will turn off UBSAN_ALIGNMENT.

[aryabinin@virtuozzo.com: changelog addition]
Link: http://lkml.kernel.org/r/20181217150326.30933-1-anders.roxell@linaro.org
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/Kconfig.ubsan

index 98fa559ebd808698ecc3774bf88c5bdea1988f27..a2ae4a8e4fa675e4dc9c9401f4ee86dbff669989 100644 (file)
@@ -27,15 +27,19 @@ config UBSAN_SANITIZE_ALL
          Enabling this option will get kernel image size increased
          significantly.
 
-config UBSAN_ALIGNMENT
-       bool "Enable checking of pointers alignment"
+config UBSAN_NO_ALIGNMENT
+       bool "Disable checking of pointers alignment"
        depends on UBSAN
-       default y if !HAVE_EFFICIENT_UNALIGNED_ACCESS
+       default y if HAVE_EFFICIENT_UNALIGNED_ACCESS
        help
-         This option enables detection of unaligned memory accesses.
-         Enabling this option on architectures that support unaligned
+         This option disables the check of unaligned memory accesses.
+         This option should be used when building allmodconfig.
+         Disabling this option on architectures that support unaligned
          accesses may produce a lot of false positives.
 
+config UBSAN_ALIGNMENT
+       def_bool !UBSAN_NO_ALIGNMENT
+
 config TEST_UBSAN
        tristate "Module for testing for undefined behavior detection"
        depends on m && UBSAN