]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
kern/dl: Check for the SHF_INFO_LINK flag in grub_dl_relocate_symbols()
authorB Horn <b@horn.uk>
Thu, 7 Nov 2024 06:00:36 +0000 (06:00 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 13 Feb 2025 14:45:55 +0000 (15:45 +0100)
The grub_dl_relocate_symbols() iterates through the sections in
an ELF looking for relocation sections. According to the spec [1]
the SHF_INFO_LINK flag should be set if the sh_info field is meant
to be a section index.

[1] https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html

Reported-by: B Horn <b@horn.uk>
Signed-off-by: B Horn <b@horn.uk>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/dl.c

index acc6ccad64c76f5185074165383624bb579ba3c1..de8c3aa8de5dbf4caf16ca851b8eb5b53de85099 100644 (file)
@@ -623,6 +623,9 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
        grub_dl_segment_t seg;
        grub_err_t err;
 
+       if (!(s->sh_flags & SHF_INFO_LINK))
+         continue;
+
        /* Find the target segment.  */
        for (seg = mod->segment; seg; seg = seg->next)
          if (seg->section == s->sh_info)