Skip to content

Commit 1a6a1db

Browse files
roxelltorvalds
authored andcommitted
lib/ubsan: default UBSAN_ALIGNMENT to not set
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>
1 parent 663cb63 commit 1a6a1db

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎lib/Kconfig.ubsan‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@ config UBSAN_SANITIZE_ALL
2727
Enabling this option will get kernel image size increased
2828
significantly.
2929

30-
config UBSAN_ALIGNMENT
31-
bool "Enable checking of pointers alignment"
30+
config UBSAN_NO_ALIGNMENT
31+
bool "Disable checking of pointers alignment"
3232
depends on UBSAN
33-
default y if !HAVE_EFFICIENT_UNALIGNED_ACCESS
33+
default y if HAVE_EFFICIENT_UNALIGNED_ACCESS
3434
help
35-
This option enables detection of unaligned memory accesses.
36-
Enabling this option on architectures that support unaligned
35+
This option disables the check of unaligned memory accesses.
36+
This option should be used when building allmodconfig.
37+
Disabling this option on architectures that support unaligned
3738
accesses may produce a lot of false positives.
3839

40+
config UBSAN_ALIGNMENT
41+
def_bool !UBSAN_NO_ALIGNMENT
42+
3943
config TEST_UBSAN
4044
tristate "Module for testing for undefined behavior detection"
4145
depends on m && UBSAN

0 commit comments

Comments
 (0)