aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2018-02-06 18:37:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-06 21:32:44 -0500
commit2bc2f688fdf8808de4f36be563ccdb0bde7c0c54 (patch)
tree7a3be72336e99a09110442813a37e8b571942f71
parent2b8383927525d6281cbad1cc70a83d2319eeae47 (diff)
Makefile: move stack-protector availability out of Kconfig
Various portions of the kernel, especially per-architecture pieces, need to know if the compiler is building with the stack protector. This was done in the arch/Kconfig with 'select', but this doesn't allow a way to do auto-detected compiler support. In preparation for creating an on-if-available default, move the logic for the definition of CONFIG_CC_STACKPROTECTOR into the Makefile. Link: http://lkml.kernel.org/r/1510076320-69931-3-git-send-email-keescook@chromium.org Signed-off-by: Kees Cook <keescook@chromium.org> Tested-by: Laura Abbott <labbott@redhat.com> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Makefile6
-rw-r--r--arch/Kconfig8
-rw-r--r--arch/x86/Kconfig2
3 files changed, 6 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 20b1aa928d78..f0f934097f64 100644
--- a/Makefile
+++ b/Makefile
@@ -693,7 +693,7 @@ else
693endif 693endif
694endif 694endif
695# Find arch-specific stack protector compiler sanity-checking script. 695# Find arch-specific stack protector compiler sanity-checking script.
696ifdef CONFIG_CC_STACKPROTECTOR 696ifdef stackp-name
697 stackp-path := $(srctree)/scripts/gcc-$(SRCARCH)_$(BITS)-has-stack-protector.sh 697 stackp-path := $(srctree)/scripts/gcc-$(SRCARCH)_$(BITS)-has-stack-protector.sh
698 stackp-check := $(wildcard $(stackp-path)) 698 stackp-check := $(wildcard $(stackp-path))
699 # If the wildcard test matches a test script, run it to check functionality. 699 # If the wildcard test matches a test script, run it to check functionality.
@@ -702,6 +702,10 @@ ifdef CONFIG_CC_STACKPROTECTOR
702 stackp-broken := y 702 stackp-broken := y
703 endif 703 endif
704 endif 704 endif
705 ifndef stackp-broken
706 # If the stack protector is functional, enable code that depends on it.
707 KBUILD_CPPFLAGS += -DCONFIG_CC_STACKPROTECTOR
708 endif
705endif 709endif
706KBUILD_CFLAGS += $(stackp-flag) 710KBUILD_CFLAGS += $(stackp-flag)
707 711
diff --git a/arch/Kconfig b/arch/Kconfig
index 467dfa35bf96..9330a9d79dc3 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -538,12 +538,6 @@ config HAVE_CC_STACKPROTECTOR
538 - its compiler supports the -fstack-protector option 538 - its compiler supports the -fstack-protector option
539 - it has implemented a stack canary (e.g. __stack_chk_guard) 539 - it has implemented a stack canary (e.g. __stack_chk_guard)
540 540
541config CC_STACKPROTECTOR
542 def_bool n
543 help
544 Set when a stack-protector mode is enabled, so that the build
545 can enable kernel-side support for the GCC feature.
546
547choice 541choice
548 prompt "Stack Protector buffer overflow detection" 542 prompt "Stack Protector buffer overflow detection"
549 depends on HAVE_CC_STACKPROTECTOR 543 depends on HAVE_CC_STACKPROTECTOR
@@ -564,7 +558,6 @@ config CC_STACKPROTECTOR_NONE
564 558
565config CC_STACKPROTECTOR_REGULAR 559config CC_STACKPROTECTOR_REGULAR
566 bool "Regular" 560 bool "Regular"
567 select CC_STACKPROTECTOR
568 help 561 help
569 Functions will have the stack-protector canary logic added if they 562 Functions will have the stack-protector canary logic added if they
570 have an 8-byte or larger character array on the stack. 563 have an 8-byte or larger character array on the stack.
@@ -578,7 +571,6 @@ config CC_STACKPROTECTOR_REGULAR
578 571
579config CC_STACKPROTECTOR_STRONG 572config CC_STACKPROTECTOR_STRONG
580 bool "Strong" 573 bool "Strong"
581 select CC_STACKPROTECTOR
582 help 574 help
583 Functions will have the stack-protector canary logic added in any 575 Functions will have the stack-protector canary logic added in any
584 of the following conditions: 576 of the following conditions:
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index b0771ceabb4b..d9878f1f3bac 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -322,7 +322,7 @@ config X86_64_SMP
322 322
323config X86_32_LAZY_GS 323config X86_32_LAZY_GS
324 def_bool y 324 def_bool y
325 depends on X86_32 && !CC_STACKPROTECTOR 325 depends on X86_32 && CC_STACKPROTECTOR_NONE
326 326
327config ARCH_SUPPORTS_UPROBES 327config ARCH_SUPPORTS_UPROBES
328 def_bool y 328 def_bool y