All of lore.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; 16+ 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] 16+ messages in thread
* Re: [PATCH] x86/build: Move _etext to actual end of .text
@ 2019-06-01  8:51 Klaus Kusche
  0 siblings, 0 replies; 16+ messages in thread
From: Klaus Kusche @ 2019-06-01  8:51 UTC (permalink / raw)
  To: keescook, johannes.hirte; +Cc: bp, samitolvanen, linux-kernel


Hello,

same problem here.

gcc version 9.1.0 (Gentoo 9.1.0 p1.0)
linux-5.1.6

RELOCS  arch/x86/boot/compressed/vmlinux.relocs
Invalid absolute R_X86_64_32S relocation: _etext
make[2]: *** [arch/x86/boot/compressed/Makefile:130: arch/x86/boot/compressed/vmlinux.relocs] Error 1
make[2]: *** Deleting file 'arch/x86/boot/compressed/vmlinux.relocs'
make[2]: *** Waiting for unfinished jobs....

make clean or make distclean did *not* help.

-- 
Prof. Dr. Klaus Kusche
Private address: Rosenberg 41, 07546 Gera, Germany
+49 365 20413058 klaus.kusche@computerix.info https://www.computerix.info
Office address: DHGE Gera, Weg der Freundschaft 4, 07546 Gera, Germany
+49 365 4341 306 klaus.kusche@dhge.de https://www.dhge.de

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH] x86/build: Move _etext to actual end of .text
@ 2019-06-05 16:08 Alec Ari
  2019-06-05 18:16 ` Kees Cook
  0 siblings, 1 reply; 16+ messages in thread
From: Alec Ari @ 2019-06-05 16:08 UTC (permalink / raw)
  To: linux-kernel, x86, Kees Cook

Hi,

I'm having this problem too, build is failing:

Invalid absolute R_X86_64_32S relocation: _etext

I stayed on the 4.14 branch to help prevent these kind of breakages,
so much for that idea. Gentoo GCC 8.3.0.

Alec

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH] x86/build: Move _etext to actual end of .text
@ 2019-06-09  9:35 Klaus Kusche
  2019-06-09 18:40 ` Johannes Hirte
  0 siblings, 1 reply; 16+ messages in thread
From: Klaus Kusche @ 2019-06-09  9:35 UTC (permalink / raw)
  To: keescook, johannes.hirte; +Cc: bp, samitolvanen, linux-kernel


Hello,

Same problem for linux 5.1.7: 
Kernel building fails with the same relocation error.

5.1.5 does not have the problem, builds fine for me.

Is there anything I can do to investigate the problem?


-- 
Prof. Dr. Klaus Kusche
Private address: Rosenberg 41, 07546 Gera, Germany
+49 365 20413058 klaus.kusche@computerix.info https://www.computerix.info
Office address: DHGE Gera, Weg der Freundschaft 4, 07546 Gera, Germany
+49 365 4341 306 klaus.kusche@dhge.de https://www.dhge.de

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

end of thread, other threads:[~2019-06-20 17:58 UTC | newest]

Thread overview: 16+ 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
2019-06-01  8:51 Klaus Kusche
2019-06-05 16:08 Alec Ari
2019-06-05 18:16 ` Kees Cook
2019-06-05 18:43   ` Greg KH
2019-06-09  9:35 Klaus Kusche
2019-06-09 18:40 ` Johannes Hirte
2019-06-19 18:37   ` Ross Zwisler
2019-06-20 17:58     ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.