aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--security/Kconfig.hardening14
2 files changed, 19 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index c0a34064c574..a7d9c6cd0267 100644
--- a/Makefile
+++ b/Makefile
@@ -745,6 +745,11 @@ KBUILD_CFLAGS += -fomit-frame-pointer
745endif 745endif
746endif 746endif
747 747
748# Initialize all stack variables with a pattern, if desired.
749ifdef CONFIG_INIT_STACK_ALL
750KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
751endif
752
748DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments) 753DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments)
749 754
750ifdef CONFIG_DEBUG_INFO 755ifdef CONFIG_DEBUG_INFO
diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening
index a96d4a43ca65..0a1d4ca314f4 100644
--- a/security/Kconfig.hardening
+++ b/security/Kconfig.hardening
@@ -18,9 +18,13 @@ config GCC_PLUGIN_STRUCTLEAK
18 18
19menu "Memory initialization" 19menu "Memory initialization"
20 20
21config CC_HAS_AUTO_VAR_INIT
22 def_bool $(cc-option,-ftrivial-auto-var-init=pattern)
23
21choice 24choice
22 prompt "Initialize kernel stack variables at function entry" 25 prompt "Initialize kernel stack variables at function entry"
23 default GCC_PLUGIN_STRUCTLEAK_BYREF_ALL if COMPILE_TEST && GCC_PLUGINS 26 default GCC_PLUGIN_STRUCTLEAK_BYREF_ALL if COMPILE_TEST && GCC_PLUGINS
27 default INIT_STACK_ALL if COMPILE_TEST && CC_HAS_AUTO_VAR_INIT
24 default INIT_STACK_NONE 28 default INIT_STACK_NONE
25 help 29 help
26 This option enables initialization of stack variables at 30 This option enables initialization of stack variables at
@@ -76,6 +80,16 @@ choice
76 of uninitialized stack variable exploits and information 80 of uninitialized stack variable exploits and information
77 exposures. 81 exposures.
78 82
83 config INIT_STACK_ALL
84 bool "0xAA-init everything on the stack (strongest)"
85 depends on CC_HAS_AUTO_VAR_INIT
86 help
87 Initializes everything on the stack with a 0xAA
88 pattern. This is intended to eliminate all classes
89 of uninitialized stack variable exploits and information
90 exposures, even variables that were warned to have been
91 left uninitialized.
92
79endchoice 93endchoice
80 94
81config GCC_PLUGIN_STRUCTLEAK_VERBOSE 95config GCC_PLUGIN_STRUCTLEAK_VERBOSE