]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.11/kbuild-add-fno-stack-check-to-kernel-build-options.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.11 / kbuild-add-fno-stack-check-to-kernel-build-options.patch
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Linus Torvalds <torvalds@linux-foundation.org>
10
11 commit 3ce120b16cc548472f80cf8644f90eda958cf1b6 upstream.
12
13 It appears that hardened gentoo enables "-fstack-check" by default for
14 gcc.
15
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.
21
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
24 issue. ]
25
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>
33
34 ---
35 Makefile | 3 +++
36 1 file changed, 3 insertions(+)
37
38 --- a/Makefile
39 +++ b/Makefile
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)
43
44 +# Make sure -fstack-check isn't enabled (like gentoo apparently did)
45 +KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,)
46 +
47 # conserve stack if available
48 KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
49