public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/build: Move _etext to actual end of .text
@ 2019-04-23 18:38 Kees Cook
  2019-04-24 11:12 ` [tip:x86/mm] " tip-bot for Kees Cook
  2019-05-14 12:04 ` [PATCH] " Johannes Hirte
  0 siblings, 2 replies; 8+ messages in thread
From: Kees Cook @ 2019-04-23 18:38 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Sami Tolvanen, linux-kernel, x86

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>
---
 arch/x86/kernel/vmlinux.lds.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index bad8c51fee6e..de94da2366e7 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -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
-- 
2.17.1


-- 
Kees Cook

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-05-16 17:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-23 18:38 [PATCH] x86/build: Move _etext to actual end of .text Kees Cook
2019-04-24 11:12 ` [tip:x86/mm] " tip-bot for Kees Cook
2019-05-14 12:04 ` [PATCH] " Johannes Hirte
2019-05-14 15:43   ` Kees Cook
2019-05-14 16:10     ` Johannes Hirte
2019-05-15 18:54       ` Kees Cook
2019-05-16 13:56         ` Johannes Hirte
2019-05-16 17:51           ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox