]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.165/efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.165 / efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch
1 From foo@baz Wed Nov 21 18:50:39 CET 2018
2 From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
3 Date: Fri, 18 Aug 2017 20:49:37 +0100
4 Subject: efi/libstub/arm64: Set -fpie when building the EFI stub
5
6 From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
7
8 commit 91ee5b21ee026c49e4e7483de69b55b8b47042be upstream.
9
10 Clang may emit absolute symbol references when building in non-PIC mode,
11 even when using the default 'small' code model, which is already mostly
12 position independent to begin with, due to its use of adrp/add pairs
13 that have a relative range of +/- 4 GB. The remedy is to pass the -fpie
14 flag, which can be done safely now that the code has been updated to avoid
15 GOT indirections (which may be emitted due to the compiler assuming that
16 the PIC/PIE code may end up in a shared library that is subject to ELF
17 symbol preemption)
18
19 Passing -fpie when building code that needs to execute at an a priori
20 unknown offset is arguably an improvement in any case, and given that
21 the recent visibility changes allow the PIC build to pass with GCC as
22 well, let's add -fpie for all arm64 builds rather than only for Clang.
23
24 Tested-by: Matthias Kaehlcke <mka@chromium.org>
25 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
26 Cc: Linus Torvalds <torvalds@linux-foundation.org>
27 Cc: Matt Fleming <matt@codeblueprint.co.uk>
28 Cc: Peter Zijlstra <peterz@infradead.org>
29 Cc: Thomas Gleixner <tglx@linutronix.de>
30 Cc: linux-efi@vger.kernel.org
31 Link: http://lkml.kernel.org/r/20170818194947.19347-5-ard.biesheuvel@linaro.org
32 Signed-off-by: Ingo Molnar <mingo@kernel.org>
33 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
34 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35 ---
36 drivers/firmware/efi/libstub/Makefile | 2 +-
37 1 file changed, 1 insertion(+), 1 deletion(-)
38
39 --- a/drivers/firmware/efi/libstub/Makefile
40 +++ b/drivers/firmware/efi/libstub/Makefile
41 @@ -10,7 +10,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__K
42 -fPIC -fno-strict-aliasing -mno-red-zone \
43 -mno-mmx -mno-sse -DDISABLE_BRANCH_PROFILING
44
45 -cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS))
46 +cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) -fpie
47 cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
48 -fno-builtin -fpic -mno-single-pic-base
49