Skip to content

Commit 8d58f22

Browse files
keestorvalds
authored andcommitted
ubsan: disable UBSAN_ALIGNMENT under COMPILE_TEST
The documentation for UBSAN_ALIGNMENT already mentions that it should not be used on all*config builds (and for efficient-unaligned-access architectures), so just refactor the Kconfig to correctly implement this so randconfigs will stop creating insane images that freak out objtool under CONFIG_UBSAN_TRAP (due to the false positives producing functions that never return, etc). Link: http://lkml.kernel.org/r/202005011433.C42EA3E2D@keescook Fixes: 0887a7e ("ubsan: add trap instrumentation option") Signed-off-by: Kees Cook <[email protected]> Reported-by: Randy Dunlap <[email protected]> Link: https://lore.kernel.org/linux-next/202004231224.D6B3B650@keescook/ Signed-off-by: Andrew Morton <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Andrey Ryabinin <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 17e3452 commit 8d58f22

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

lib/Kconfig.ubsan

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,15 @@ config UBSAN_SANITIZE_ALL
6060
Enabling this option will get kernel image size increased
6161
significantly.
6262

63-
config UBSAN_NO_ALIGNMENT
64-
bool "Disable checking of pointers alignment"
65-
default y if HAVE_EFFICIENT_UNALIGNED_ACCESS
63+
config UBSAN_ALIGNMENT
64+
bool "Enable checks for pointers alignment"
65+
default !HAVE_EFFICIENT_UNALIGNED_ACCESS
66+
depends on !X86 || !COMPILE_TEST
6667
help
67-
This option disables the check of unaligned memory accesses.
68-
This option should be used when building allmodconfig.
69-
Disabling this option on architectures that support unaligned
68+
This option enables the check of unaligned memory accesses.
69+
Enabling this option on architectures that support unaligned
7070
accesses may produce a lot of false positives.
7171

72-
config UBSAN_ALIGNMENT
73-
def_bool !UBSAN_NO_ALIGNMENT
74-
7572
config TEST_UBSAN
7673
tristate "Module for testing for undefined behavior detection"
7774
depends on m

tools/testing/selftests/wireguard/qemu/debug.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ CONFIG_KASAN=y
2525
CONFIG_KASAN_INLINE=y
2626
CONFIG_UBSAN=y
2727
CONFIG_UBSAN_SANITIZE_ALL=y
28-
CONFIG_UBSAN_NO_ALIGNMENT=y
2928
CONFIG_UBSAN_NULL=y
3029
CONFIG_DEBUG_KMEMLEAK=y
3130
CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=8192

0 commit comments

Comments
 (0)