kernel/modsign-fix-elf-rel.patch

27 lines
923 B
Diff

--- a/kernel/module-verify.c
+++ a/kernel/module-verify.c
@@ -391,16 +391,19 @@ static int extract_elf_rel(struct module_verify_data *mvdata,
#endif
} __packed relocation;
+ const Elf_Shdr *relsec, *symsec, *strsec;
const Elf_Rel *reloc;
const Elf_Sym *symbols, *symbol;
const char *strings;
unsigned long r_sym;
size_t nsyms, loop;
- nsyms = mvdata->sections[secix].sh_size / sizeof(Elf_Sym);
- symbols = mvdata->buffer + mvdata->sections[secix].sh_offset;
- strings = mvdata->buffer +
- mvdata->sections[mvdata->sections[secix].sh_link].sh_offset;
+ relsec = &mvdata->sections[secix];
+ symsec = &mvdata->sections[relsec->sh_link];
+ strsec = &mvdata->sections[symsec->sh_link];
+ nsyms = symsec->sh_size / sizeof(Elf_Sym);
+ symbols = mvdata->buffer + symsec->sh_offset;
+ strings = mvdata->buffer + strsec->sh_offset;
/* Contribute the relevant bits from a join of
* { REL, SYMBOL, SECTION }