Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19952a92 authored by Kees Cook's avatar Kees Cook Committed by Ingo Molnar
Browse files

stackprotector: Unify the HAVE_CC_STACKPROTECTOR logic between architectures



Instead of duplicating the CC_STACKPROTECTOR Kconfig and
Makefile logic in each architecture, switch to using
HAVE_CC_STACKPROTECTOR and keep everything in one place. This
retains the x86-specific bug verification scripts.

Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mips@linux-mips.org
Cc: linux-arch@vger.kernel.org
Link: http://lkml.kernel.org/r/1387481759-14535-2-git-send-email-keescook@chromium.org


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent b0031f22
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -595,10 +595,18 @@ ifneq ($(CONFIG_FRAME_WARN),0)
KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
endif

# Force gcc to behave correct even for buggy distributions
ifndef CONFIG_CC_STACKPROTECTOR
KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
# Handle stack protector mode.
ifdef CONFIG_CC_STACKPROTECTOR
  stackp-flag := -fstack-protector
  ifeq ($(call cc-option, $(stackp-flag)),)
    $(warning Cannot use CONFIG_CC_STACKPROTECTOR: \
	      -fstack-protector not supported by compiler))
  endif
else
  # Force off for distro compilers that enable stack protector by default.
  stackp-flag := $(call cc-option, -fno-stack-protector)
endif
KBUILD_CFLAGS += $(stackp-flag)

# This warning generated too much noise in a regular build.
# Use make W=1 to enable this warning (see scripts/Makefile.build)
+22 −0
Original line number Diff line number Diff line
@@ -336,6 +336,28 @@ config SECCOMP_FILTER

	  See Documentation/prctl/seccomp_filter.txt for details.

config HAVE_CC_STACKPROTECTOR
	bool
	help
	  An arch should select this symbol if:
	  - its compiler supports the -fstack-protector option
	  - it has implemented a stack canary (e.g. __stack_chk_guard)

config CC_STACKPROTECTOR
	bool "Enable -fstack-protector buffer overflow detection"
	depends on HAVE_CC_STACKPROTECTOR
	help
	  This option turns on the -fstack-protector GCC feature. This
	  feature puts, at the beginning of functions, a canary value on
	  the stack just before the return address, and validates
	  the value just before actually returning.  Stack based buffer
	  overflows (that need to overwrite this return address) now also
	  overwrite the canary, which gets detected and the attack is then
	  neutralized via a kernel panic.

	  This feature requires gcc version 4.2 or above, or a distribution
	  gcc with the feature backported.

config HAVE_CONTEXT_TRACKING
	bool
	help
+1 −12
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ config ARM
	select HAVE_BPF_JIT
	select HAVE_CONTEXT_TRACKING
	select HAVE_C_RECORDMCOUNT
	select HAVE_CC_STACKPROTECTOR
	select HAVE_DEBUG_KMEMLEAK
	select HAVE_DMA_API_DEBUG
	select HAVE_DMA_ATTRS
@@ -1856,18 +1857,6 @@ config SECCOMP
	  and the task is only allowed to execute a few safe syscalls
	  defined by each seccomp mode.

config CC_STACKPROTECTOR
	bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)"
	help
	  This option turns on the -fstack-protector GCC feature. This
	  feature puts, at the beginning of functions, a canary value on
	  the stack just before the return address, and validates
	  the value just before actually returning.  Stack based buffer
	  overflows (that need to overwrite this return address) now also
	  overwrite the canary, which gets detected and the attack is then
	  neutralized via a kernel panic.
	  This feature requires gcc version 4.2 or above.

config SWIOTLB
	def_bool y

+0 −4
Original line number Diff line number Diff line
@@ -40,10 +40,6 @@ ifeq ($(CONFIG_FRAME_POINTER),y)
KBUILD_CFLAGS	+=-fno-omit-frame-pointer -mapcs -mno-sched-prolog
endif

ifeq ($(CONFIG_CC_STACKPROTECTOR),y)
KBUILD_CFLAGS	+=-fstack-protector
endif

ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
KBUILD_CPPFLAGS	+= -mbig-endian
AS		+= -EB
+1 −13
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ config MIPS
	select MODULES_USE_ELF_RELA if MODULES && 64BIT
	select CLONE_BACKWARDS
	select HAVE_DEBUG_STACKOVERFLOW
	select HAVE_CC_STACKPROTECTOR

menu "Machine selection"

@@ -2322,19 +2323,6 @@ config SECCOMP

	  If unsure, say Y. Only embedded should say N here.

config CC_STACKPROTECTOR
	bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)"
	help
	  This option turns on the -fstack-protector GCC feature. This
	  feature puts, at the beginning of functions, a canary value on
	  the stack just before the return address, and validates
	  the value just before actually returning.  Stack based buffer
	  overflows (that need to overwrite this return address) now also
	  overwrite the canary, which gets detected and the attack is then
	  neutralized via a kernel panic.

	  This feature requires gcc version 4.2 or above.

config USE_OF
	bool
	select OF
Loading