]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/boot: Ignore relocations in .notes sections in walk_relocs() too
authorGuixiong Wei <weiguixiong@bytedance.com>
Sun, 17 Mar 2024 15:05:47 +0000 (23:05 +0800)
committerIngo Molnar <mingo@kernel.org>
Fri, 22 Mar 2024 08:48:59 +0000 (09:48 +0100)
Commit:

  aaa8736370db ("x86, relocs: Ignore relocations in .notes section")

... only started ignoring the .notes sections in print_absolute_relocs(),
but the same logic should also by applied in walk_relocs() to avoid
such relocations.

[ mingo: Fixed various typos in the changelog, removed extra curly braces from the code. ]

Fixes: aaa8736370db ("x86, relocs: Ignore relocations in .notes section")
Fixes: 5ead97c84fa7 ("xen: Core Xen implementation")
Fixes: da1a679cde9b ("Add /sys/kernel/notes")
Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20240317150547.24910-1-weiguixiong@bytedance.com
arch/x86/tools/relocs.c

index b029fb81ebeee0e8d5c703f5e64b7be0dbcc0c59..e7a44a7f617fbefeba6efda23dac767756c54f15 100644 (file)
@@ -746,6 +746,15 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
                if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
                        continue;
                }
+
+               /*
+                * Do not perform relocations in .notes sections; 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;
                sym_strtab = sec_symtab->link->strtab;
                for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {