Skip to content

Commit dde5cf3

Browse files
aryabinintorvalds
authored andcommitted
ubsan: fix tree-wide -Wmaybe-uninitialized false positives
-fsanitize=* options makes GCC less smart than usual and increase number of 'maybe-uninitialized' false-positives. So this patch does two things: * Add -Wno-maybe-uninitialized to CFLAGS_UBSAN which will disable all such warnings for instrumented files. * Remove CONFIG_UBSAN_SANITIZE_ALL from all[yes|mod]config builds. So the all[yes|mod]config build goes without -fsanitize=* and still with -Wmaybe-uninitialized. Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Reported-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 21b2f44 commit dde5cf3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/Kconfig.ubsan

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ config UBSAN_SANITIZE_ALL
1313
bool "Enable instrumentation for the entire kernel"
1414
depends on UBSAN
1515
depends on ARCH_HAS_UBSAN_SANITIZE_ALL
16+
17+
# We build with -Wno-maybe-uninitilzed, but we still want to
18+
# use -Wmaybe-uninitilized in allmodconfig builds.
19+
# So dependsy bellow used to disable this option in allmodconfig
20+
depends on !COMPILE_TEST
1621
default y
1722
help
1823
This option activates instrumentation for the entire kernel.

scripts/Makefile.ubsan

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ ifdef CONFIG_UBSAN
1414
ifdef CONFIG_UBSAN_ALIGNMENT
1515
CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
1616
endif
17+
18+
# -fsanitize=* options makes GCC less smart than usual and
19+
# increase number of 'maybe-uninitialized false-positives
20+
CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)
1721
endif

0 commit comments

Comments
 (0)