Skip to content

Commit 6866469

Browse files
committed
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>
1 parent 1355680 commit 6866469

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
804804
# warn about C99 declaration after statement
805805
KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
806806

807+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
808+
KBUILD_CFLAGS += $(call cc-option,-Wvla)
809+
807810
# disable pointer signed / unsigned warnings in gcc 4.0
808811
KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
809812

drivers/gpu/drm/i915/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Note the danger in using -Wall -Wextra is that when CI updates gcc we
1313
# will most likely get a sudden build breakage... Hopefully we will fix
1414
# new warnings before CI updates!
15-
subdir-ccflags-y := -Wall -Wextra -Wvla
15+
subdir-ccflags-y := -Wall -Wextra
1616
subdir-ccflags-y += $(call cc-disable-warning, unused-parameter)
1717
subdir-ccflags-y += $(call cc-disable-warning, type-limits)
1818
subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers)

lib/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o
5353
obj-$(CONFIG_TEST_IDA) += test_ida.o
5454
obj-$(CONFIG_TEST_KASAN) += test_kasan.o
5555
CFLAGS_test_kasan.o += -fno-builtin
56+
CFLAGS_test_kasan.o += $(call cc-disable-warning, vla)
5657
obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o
58+
CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla)
5759
UBSAN_SANITIZE_test_ubsan.o := y
5860
obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
5961
obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o

scripts/Makefile.extrawarn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ warning-3 += -Wpointer-arith
5252
warning-3 += -Wredundant-decls
5353
warning-3 += -Wswitch-default
5454
warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
55-
warning-3 += $(call cc-option, -Wvla)
5655

5756
warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
5857
warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))

0 commit comments

Comments
 (0)