1 From 3ce120b16cc548472f80cf8644f90eda958cf1b6 Mon Sep 17 00:00:00 2001
2 From: Linus Torvalds <torvalds@linux-foundation.org>
3 Date: Fri, 29 Dec 2017 17:34:43 -0800
4 Subject: kbuild: add '-fno-stack-check' to kernel build options
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Linus Torvalds <torvalds@linux-foundation.org>
11 commit 3ce120b16cc548472f80cf8644f90eda958cf1b6 upstream.
13 It appears that hardened gentoo enables "-fstack-check" by default for
16 That doesn't work _at_all_ for the kernel, because the kernel stack
17 doesn't act like a user stack at all: it's much smaller, and it doesn't
18 auto-expand on use. So the extra "probe one page below the stack" code
19 generated by -fstack-check just breaks the kernel in horrible ways,
20 causing infinite double faults etc.
22 [ I have to say, that the particular code gcc generates looks very
23 stupid even for user space where it works, but that's a separate
26 Reported-and-tested-by: Alexander Tsoy <alexander@tsoy.me>
27 Reported-and-tested-by: Toralf Förster <toralf.foerster@gmx.de>
28 Cc: Dave Hansen <dave.hansen@intel.com>
29 Cc: Jiri Kosina <jikos@kernel.org>
30 Cc: Andy Lutomirski <luto@amacapital.net>
31 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36 1 file changed, 3 insertions(+)
40 @@ -802,6 +802,9 @@ KBUILD_CFLAGS += $(call cc-disable-warni
41 # disable invalid "can't wrap" optimizations for signed / pointers
42 KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
44 +# Make sure -fstack-check isn't enabled (like gentoo apparently did)
45 +KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,)
47 # conserve stack if available
48 KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)