ubsan: fix tree-wide -Wmaybe-uninitialized false positives
authorAndrey Ryabinin <aryabinin@virtuozzo.com>
Tue, 22 Mar 2016 21:27:45 +0000 (14:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2016 22:36:02 +0000 (15:36 -0700)
-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>
lib/Kconfig.ubsan
scripts/Makefile.ubsan

index e07c1ba9ba1339a80dac79d59255d80d600b096e..39494af9a84ac89e6fbbc1f25d9407c70d19e66f 100644 (file)
@@ -13,6 +13,11 @@ config UBSAN_SANITIZE_ALL
        bool "Enable instrumentation for the entire kernel"
        depends on UBSAN
        depends on ARCH_HAS_UBSAN_SANITIZE_ALL
+
+       # We build with -Wno-maybe-uninitilzed, but we still want to
+       # use -Wmaybe-uninitilized in allmodconfig builds.
+       # So dependsy bellow used to disable this option in allmodconfig
+       depends on !COMPILE_TEST
        default y
        help
          This option activates instrumentation for the entire kernel.
index 8ab68679cfb5b65cebd5f05d5d5054812bd4c651..77ce538268b5d7c4ebee9b598d17dadcd4dfd189 100644 (file)
@@ -14,4 +14,8 @@ ifdef CONFIG_UBSAN
 ifdef CONFIG_UBSAN_ALIGNMENT
       CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
 endif
+
+      # -fsanitize=* options makes GCC less smart than usual and
+      # increase number of 'maybe-uninitialized false-positives
+      CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)
 endif