From: B Horn Date: Thu, 7 Nov 2024 06:00:36 +0000 (+0000) Subject: kern/dl: Check for the SHF_INFO_LINK flag in grub_dl_relocate_symbols() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98ad84328dcabfa603dcf5bd217570aa6b4bdd99;p=thirdparty%2Fgrub.git kern/dl: Check for the SHF_INFO_LINK flag in grub_dl_relocate_symbols() 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 Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index acc6ccad6..de8c3aa8d 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -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)