diff options
author | Kees Cook <keescook@chromium.org> | 2018-06-25 18:59:34 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2018-10-11 11:17:50 -0400 |
commit | 0bb95f80a38f82884693194ea720e9cca5e12ada (patch) | |
tree | 788e8ef11abfc6b7dc7cd0ba6b7f23fa2f6b95e1 | |
parent | 81b45683487a51b0f4d3b29d37f20d6d078544e4 (diff) |
Makefile: Globally enable VLA warning
Now that Variable Length Arrays (VLAs) have been entirely removed[1]
from the kernel, enable the VLA warning globally. The only exceptions
to this are the KASan an UBSan tests which are explicitly checking that
VLAs trigger their respective tests.
[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Airlie <airlied@linux.ie>
Cc: linux-kbuild@vger.kernel.org
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/Makefile | 2 | ||||
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | scripts/Makefile.extrawarn | 1 |
4 files changed, 6 insertions, 2 deletions
@@ -804,6 +804,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) | |||
804 | # warn about C99 declaration after statement | 804 | # warn about C99 declaration after statement |
805 | KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) | 805 | KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) |
806 | 806 | ||
807 | # Variable Length Arrays (VLAs) should not be used anywhere in the kernel | ||
808 | KBUILD_CFLAGS += $(call cc-option,-Wvla) | ||
809 | |||
807 | # disable pointer signed / unsigned warnings in gcc 4.0 | 810 | # disable pointer signed / unsigned warnings in gcc 4.0 |
808 | KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) | 811 | KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) |
809 | 812 | ||
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 5794f102f9b8..1c2857f13ad4 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile | |||
@@ -12,7 +12,7 @@ | |||
12 | # Note the danger in using -Wall -Wextra is that when CI updates gcc we | 12 | # Note the danger in using -Wall -Wextra is that when CI updates gcc we |
13 | # will most likely get a sudden build breakage... Hopefully we will fix | 13 | # will most likely get a sudden build breakage... Hopefully we will fix |
14 | # new warnings before CI updates! | 14 | # new warnings before CI updates! |
15 | subdir-ccflags-y := -Wall -Wextra -Wvla | 15 | subdir-ccflags-y := -Wall -Wextra |
16 | subdir-ccflags-y += $(call cc-disable-warning, unused-parameter) | 16 | subdir-ccflags-y += $(call cc-disable-warning, unused-parameter) |
17 | subdir-ccflags-y += $(call cc-disable-warning, type-limits) | 17 | subdir-ccflags-y += $(call cc-disable-warning, type-limits) |
18 | subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers) | 18 | subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers) |
diff --git a/lib/Makefile b/lib/Makefile index ca3f7ebb900d..8e0aca8a2f09 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -53,7 +53,9 @@ obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o | |||
53 | obj-$(CONFIG_TEST_IDA) += test_ida.o | 53 | obj-$(CONFIG_TEST_IDA) += test_ida.o |
54 | obj-$(CONFIG_TEST_KASAN) += test_kasan.o | 54 | obj-$(CONFIG_TEST_KASAN) += test_kasan.o |
55 | CFLAGS_test_kasan.o += -fno-builtin | 55 | CFLAGS_test_kasan.o += -fno-builtin |
56 | CFLAGS_test_kasan.o += $(call cc-disable-warning, vla) | ||
56 | obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o | 57 | obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o |
58 | CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla) | ||
57 | UBSAN_SANITIZE_test_ubsan.o := y | 59 | UBSAN_SANITIZE_test_ubsan.o := y |
58 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o | 60 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o |
59 | obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o | 61 | obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o |
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 8d5357053f86..24b2fb1d1297 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn | |||
@@ -52,7 +52,6 @@ warning-3 += -Wpointer-arith | |||
52 | warning-3 += -Wredundant-decls | 52 | warning-3 += -Wredundant-decls |
53 | warning-3 += -Wswitch-default | 53 | warning-3 += -Wswitch-default |
54 | warning-3 += $(call cc-option, -Wpacked-bitfield-compat) | 54 | warning-3 += $(call cc-option, -Wpacked-bitfield-compat) |
55 | warning-3 += $(call cc-option, -Wvla) | ||
56 | 55 | ||
57 | warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | 56 | warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) |
58 | warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | 57 | warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) |