diff --git a/Makefile b/Makefile index c8b8e902d5a4f..c05aa678014cf 100644 --- a/Makefile +++ b/Makefile @@ -674,6 +674,10 @@ ifneq ($(CONFIG_FRAME_WARN),0) KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) endif +ifdef CONFIG_LOCAL_SANITIZE +KBUILD_CFLAGS += -fsanitize=local-sanitize +endif + # This selects the stack protector compiler flag. Testing it is delayed # until after .config has been reprocessed, in the prepare-compiler-check # target. diff --git a/init/Kconfig b/init/Kconfig index f3bc2f21c394d..585ec832277da 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1039,6 +1039,12 @@ config CC_OPTIMIZE_FOR_SIZE endchoice +config LOCAL_SANITIZE + bool "Zero uninitialized locals" + help + Zero-fill uninitialized local variables, other than variable-length + arrays. Requires compiler support. + config SYSCTL bool