Commit 758638eb authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] Don't OOPS on stripped modules

Don't want to go overboard with the checks, but this is simple and
reasonable.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (modified)
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8cc42321
...@@ -1538,9 +1538,6 @@ static struct module *load_module(void __user *umod, ...@@ -1538,9 +1538,6 @@ static struct module *load_module(void __user *umod,
secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
sechdrs[0].sh_addr = 0; sechdrs[0].sh_addr = 0;
/* And these should exist, but gcc whinges if we don't init them */
symindex = strindex = 0;
for (i = 1; i < hdr->e_shnum; i++) { for (i = 1; i < hdr->e_shnum; i++) {
if (sechdrs[i].sh_type != SHT_NOBITS if (sechdrs[i].sh_type != SHT_NOBITS
&& len < sechdrs[i].sh_offset + sechdrs[i].sh_size) && len < sechdrs[i].sh_offset + sechdrs[i].sh_size)
...@@ -1572,6 +1569,13 @@ static struct module *load_module(void __user *umod, ...@@ -1572,6 +1569,13 @@ static struct module *load_module(void __user *umod,
} }
mod = (void *)sechdrs[modindex].sh_addr; mod = (void *)sechdrs[modindex].sh_addr;
if (symindex == 0) {
printk(KERN_WARNING "%s: module has no symbols (stripped?)\n",
mod->name);
err = -ENOEXEC;
goto free_hdr;
}
/* Optional sections */ /* Optional sections */
exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab"); exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab");
gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl"); gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment