Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions kernel/module/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,7 @@ static int elf_validity_ehdr(const struct load_info *info)
* * Section array fits in the user provided data
* * Section index 0 is NULL
* * Section contents are inbounds
* * Relocation section target indices are inbounds
*
* Then updates @info with a &load_info->sechdrs pointer if valid.
*
Expand Down Expand Up @@ -1983,6 +1984,12 @@ static int elf_validity_cache_sechdrs(struct load_info *info)
/* Validate contents are inbounds */
for (i = 1; i < info->hdr->e_shnum; i++) {
shdr = &sechdrs[i];
if ((shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) &&
shdr->sh_info >= info->hdr->e_shnum) {
pr_err("Invalid ELF relocation section target index %u\n",
shdr->sh_info);
return -ENOEXEC;
}
switch (shdr->sh_type) {
case SHT_NULL:
case SHT_NOBITS:
Expand Down
Loading