lkml.org 
[lkml]   [2004]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] Oops when loading a stripped module
From
Date
On Fri, 2004-08-20 at 01:52, BlaisorBlade wrote:
> I've stripped a module and tried to load it (I know it's meaningless, but it
> was for testing; I wanted to strip debug symbols). And to my surprise, the

Thanks.

Name: Don't OOPS on stripped modules
Status: Tested on 2.6.9-rc1-bk1
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (modified)
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>

Paulo:
> I've stripped a module and tried to load it (I know it's meaningless, but it
> was for testing; I wanted to strip debug symbols). And to my surprise, the
> kernel Oopsed.

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

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9728-linux-2.6.9-rc1-bk1/kernel/module.c .9728-linux-2.6.9-rc1-bk1.updated/kernel/module.c
--- .9728-linux-2.6.9-rc1-bk1/kernel/module.c 2004-08-25 09:54:16.000000000 +1000
+++ .9728-linux-2.6.9-rc1-bk1.updated/kernel/module.c 2004-08-26 18:16:46.000000000 +1000
@@ -1538,9 +1538,6 @@ static struct module *load_module(void _
secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
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++) {
if (sechdrs[i].sh_type != SHT_NOBITS
&& len < sechdrs[i].sh_offset + sechdrs[i].sh_size)
@@ -1572,6 +1569,13 @@ static struct module *load_module(void _
}
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 */
exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab");
gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl");
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:05    [W:0.030 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site