Skip to content

Commit 815d680

Browse files
keesIngo Molnar
authored andcommitted
x86/build: Enforce an empty .got.plt section
The .got.plt section should always be zero (or filled only with the linker-generated lazy dispatch entry). Enforce this with an assert and mark the section as INFO. This is more sensitive than just blindly discarding the section. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20200821194310.3089815-24-keescook@chromium.org
1 parent a850958 commit 815d680

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

arch/x86/kernel/vmlinux.lds.S

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,20 @@ SECTIONS
414414
ELF_DETAILS
415415

416416
DISCARDS
417-
}
418417

418+
/*
419+
* Make sure that the .got.plt is either completely empty or it
420+
* contains only the lazy dispatch entries.
421+
*/
422+
.got.plt (INFO) : { *(.got.plt) }
423+
ASSERT(SIZEOF(.got.plt) == 0 ||
424+
#ifdef CONFIG_X86_64
425+
SIZEOF(.got.plt) == 0x18,
426+
#else
427+
SIZEOF(.got.plt) == 0xc,
428+
#endif
429+
"Unexpected GOT/PLT entries detected!")
430+
}
419431

420432
#ifdef CONFIG_X86_32
421433
/*

0 commit comments

Comments
 (0)