Commit aaa87363 authored by Kees Cook's avatar Kees Cook

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: default avatarGuixiong Wei <guixiongwei@gmail.com>
Closes: https://lore.kernel.org/all/20240218073501.54555-1-guixiongwei@gmail.com/
Fixes: 5ead97c8 ("xen: Core Xen implementation")
Fixes: da1a679c ("Add /sys/kernel/notes")
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent 10b4c4bc
...@@ -653,6 +653,14 @@ static void print_absolute_relocs(void) ...@@ -653,6 +653,14 @@ static void print_absolute_relocs(void)
if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) { if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
continue; continue;
} }
/*
* Do not perform relocations in .notes section; any
* values there are meant for pre-boot consumption (e.g.
* startup_xen).
*/
if (sec_applies->shdr.sh_type == SHT_NOTE) {
continue;
}
sh_symtab = sec_symtab->symtab; sh_symtab = sec_symtab->symtab;
sym_strtab = sec_symtab->link->strtab; sym_strtab = sec_symtab->link->strtab;
for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) { for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment