Skip to content

Commit aaa8736

Browse files
committed
x86, relocs: Ignore relocations in .notes section
When building with CONFIG_XEN_PV=y, .text symbols are emitted into the .notes section so that Xen can find the "startup_xen" entry point. This information is used prior to booting the kernel, so relocations are not useful. In fact, performing relocations against the .notes section means that the KASLR base is exposed since /sys/kernel/notes is world-readable. To avoid leaking the KASLR base without breaking unprivileged tools that are expecting to read /sys/kernel/notes, skip performing relocations in the .notes section. The values readable in .notes are then identical to those found in System.map. Reported-by: Guixiong Wei <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Fixes: 5ead97c ("xen: Core Xen implementation") Fixes: da1a679 ("Add /sys/kernel/notes") Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent 10b4c4b commit aaa8736

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/x86/tools/relocs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,14 @@ static void print_absolute_relocs(void)
653653
if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
654654
continue;
655655
}
656+
/*
657+
* Do not perform relocations in .notes section; any
658+
* values there are meant for pre-boot consumption (e.g.
659+
* startup_xen).
660+
*/
661+
if (sec_applies->shdr.sh_type == SHT_NOTE) {
662+
continue;
663+
}
656664
sh_symtab = sec_symtab->symtab;
657665
sym_strtab = sec_symtab->link->strtab;
658666
for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {

0 commit comments

Comments
 (0)