aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gcc-plugins/randomize_layout_plugin.c
diff options
context:
space:
mode:
authorKees Cook <[email protected]>2025-04-18 21:32:39 +0000
committerKees Cook <[email protected]>2025-05-08 16:42:06 +0000
commit5e88c48cb4bcbd0ea683373a106268933bb4edd2 (patch)
tree30c3dfe3da2aedc31c0a231eb51a5e11bc4d2bfb /scripts/gcc-plugins/randomize_layout_plugin.c
parenthardening: simplify CONFIG_CC_HAS_COUNTED_BY (diff)
downloadkernel-5e88c48cb4bcbd0ea683373a106268933bb4edd2.tar.gz
kernel-5e88c48cb4bcbd0ea683373a106268933bb4edd2.zip
kbuild: Switch from -Wvla to -Wvla-larger-than=1
Variable Length Arrays (VLAs) on the stack must not be used in the kernel. Function parameter VLAs[1] should be usable, but -Wvla will warn for those. For example, this will produce a warning but it is not using a stack VLA: int something(size_t n, int array[n]) { ... Clang has no way yet to distinguish between the VLA types[2], so depend on GCC for now to keep stack VLAs out of the tree by using GCC's -Wvla-larger-than=N option (though GCC may split -Wvla similarly[3] to how Clang is planning to). While GCC 8+ supports -Wvla-larger-than, only 9+ supports ...=0[4], so use -Wvla-larger-than=1. Adjust mm/kasan/Makefile to remove it from CFLAGS (GCC <9 appears unable to disable the warning correctly[5]). The VLA usage in lib/test_ubsan.c was removed in commit 9d7ca61b1366 ("lib/test_ubsan.c: VLA no longer used in kernel") so the lib/Makefile disabling of VLA checking can be entirely removed. Link: https://en.cppreference.com/w/c/language/array [1] Link: https://github.com/llvm/llvm-project/issues/57098 [2] Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98217 [3] Link: https://lore.kernel.org/lkml/[email protected]/ [4] Link: https://lore.kernel.org/r/[email protected]/ [5] Reviewed-by: Nathan Chancellor <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Tested-by: Venkat Rao Bagalkote <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
Diffstat (limited to 'scripts/gcc-plugins/randomize_layout_plugin.c')
0 files changed, 0 insertions, 0 deletions