Skip to content

Commit 2bc2f68

Browse files
keestorvalds
authored andcommitted
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>
1 parent 2b83839 commit 2bc2f68

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

‎Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ else
693693
endif
694694
endif
695695
# Find arch-specific stack protector compiler sanity-checking script.
696-
ifdef CONFIG_CC_STACKPROTECTOR
696+
ifdef stackp-name
697697
stackp-path := $(srctree)/scripts/gcc-$(SRCARCH)_$(BITS)-has-stack-protector.sh
698698
stackp-check := $(wildcard $(stackp-path))
699699
# If the wildcard test matches a test script, run it to check functionality.
@@ -702,6 +702,10 @@ ifdef CONFIG_CC_STACKPROTECTOR
702702
stackp-broken := y
703703
endif
704704
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
705709
endif
706710
KBUILD_CFLAGS += $(stackp-flag)
707711

‎arch/Kconfig‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,6 @@ config HAVE_CC_STACKPROTECTOR
538538
- its compiler supports the -fstack-protector option
539539
- it has implemented a stack canary (e.g. __stack_chk_guard)
540540

541-
config 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-
547541
choice
548542
prompt "Stack Protector buffer overflow detection"
549543
depends on HAVE_CC_STACKPROTECTOR
@@ -564,7 +558,6 @@ config CC_STACKPROTECTOR_NONE
564558

565559
config CC_STACKPROTECTOR_REGULAR
566560
bool "Regular"
567-
select CC_STACKPROTECTOR
568561
help
569562
Functions will have the stack-protector canary logic added if they
570563
have an 8-byte or larger character array on the stack.
@@ -578,7 +571,6 @@ config CC_STACKPROTECTOR_REGULAR
578571

579572
config CC_STACKPROTECTOR_STRONG
580573
bool "Strong"
581-
select CC_STACKPROTECTOR
582574
help
583575
Functions will have the stack-protector canary logic added in any
584576
of the following conditions:

‎arch/x86/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ config X86_64_SMP
322322

323323
config X86_32_LAZY_GS
324324
def_bool y
325-
depends on X86_32 && !CC_STACKPROTECTOR
325+
depends on X86_32 && CC_STACKPROTECTOR_NONE
326326

327327
config ARCH_SUPPORTS_UPROBES
328328
def_bool y

0 commit comments

Comments
 (0)