[tip: x86/urgent] x86/build: Fix linker fill bytes quirk/incompatibility for ld.lld

From: tip-bot2 for Song Liu
Date: Wed Sep 06 2023 - 17:57:23 EST


The following commit has been merged into the x86/urgent branch of tip:

Commit-ID: 65e710899fd19f435f40268f3a92dfaa11f14470
Gitweb: https://git.kernel.org/tip/65e710899fd19f435f40268f3a92dfaa11f14470
Author: Song Liu <song@xxxxxxxxxx>
AuthorDate: Wed, 06 Sep 2023 10:52:15 -07:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Wed, 06 Sep 2023 23:49:12 +02:00

x86/build: Fix linker fill bytes quirk/incompatibility for ld.lld

With ":text =0xcccc", ld.lld fills unused text area with 0xcccc0000.
Example objdump -D output:

ffffffff82b04203: 00 00 add %al,(%rax)
ffffffff82b04205: cc int3
ffffffff82b04206: cc int3
ffffffff82b04207: 00 00 add %al,(%rax)
ffffffff82b04209: cc int3
ffffffff82b0420a: cc int3

Replace it with ":text =0xcccccccc", so we get the following instead:

ffffffff82b04203: cc int3
ffffffff82b04204: cc int3
ffffffff82b04205: cc int3
ffffffff82b04206: cc int3
ffffffff82b04207: cc int3
ffffffff82b04208: cc int3

gcc/ld doesn't seem to have the same issue. The generated code stays the
same for gcc/ld.

Signed-off-by: Song Liu <song@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Fixes: 7705dc855797 ("x86/vmlinux: Use INT3 instead of NOP for linker fill bytes")
Link: https://lore.kernel.org/r/20230906175215.2236033-1-song@xxxxxxxxxx
---
arch/x86/kernel/vmlinux.lds.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 83d41c2..f15fb71 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -156,7 +156,7 @@ SECTIONS
ALIGN_ENTRY_TEXT_END
*(.gnu.warning)

- } :text =0xcccc
+ } :text = 0xcccccccc

/* End of text section, which should occupy whole number of pages */
_etext = .;