Skip to content

Commit

Permalink
Guard check in module loader against integer overflow
Browse files Browse the repository at this point in the history
The check:

	if (len < hdr->e_shoff + hdr->e_shnum * sizeof(Elf_Shdr))

may not work if there's an overflow in the right-hand side of the condition.

Signed-off-by: David Howells <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
dhowells authored and rustyrussell committed May 23, 2012
1 parent 3c7ec94 commit ef26a5a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,8 @@ static int copy_and_check(struct load_info *info,
goto free_hdr;
}

if (len < hdr->e_shoff + hdr->e_shnum * sizeof(Elf_Shdr)) {
if (hdr->e_shoff >= len ||
hdr->e_shnum * sizeof(Elf_Shdr) > len - hdr->e_shoff) {
err = -ENOEXEC;
goto free_hdr;
}
Expand Down

0 comments on commit ef26a5a

Please sign in to comment.