From 9e84af76a8c3c1022fe2f782cb2245bbd39fe197 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Wed, 24 Jan 2018 23:54:08 -0500 Subject: [PATCH] wire up -fsanitize=local-init --- Makefile | 4 ++++ init/Kconfig | 6 ++++++ 2 files changed, 10 insertions(+) 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