x86/build: Move _etext to actual end of .text
authorKees Cook <keescook@chromium.org>
Tue, 23 Apr 2019 18:38:27 +0000 (11:38 -0700)
committerIngo Molnar <mingo@kernel.org>
Wed, 24 Apr 2019 10:27:47 +0000 (12:27 +0200)
When building x86 with Clang LTO and CFI, CFI jump regions are
automatically added to the end of the .text section late in linking. As a
result, the _etext position was being labelled before the appended jump
regions, causing confusion about where the boundaries of the executable
region actually are in the running kernel, and broke at least the fault
injection code. This moves the _etext mark to outside (and immediately
after) the .text area, as it already the case on other architectures
(e.g. arm64, arm).

Reported-and-tested-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20190423183827.GA4012@beast
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/vmlinux.lds.S

index bad8c51fee6eea6be91d7a594e820470c121c2a9..de94da2366e7828543e4ec2e335f178e52862474 100644 (file)
@@ -141,11 +141,11 @@ SECTIONS
                *(.text.__x86.indirect_thunk)
                __indirect_thunk_end = .;
 #endif
-
-               /* End of text section */
-               _etext = .;
        } :text = 0x9090
 
+       /* End of text section */
+       _etext = .;
+
        NOTES :text :note
 
        EXCEPTION_TABLE(16) :text = 0x9090