All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: BlaisorBlade <blaisorblade_spam@yahoo.it>
Cc: lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] Oops when loading a stripped module
Date: Thu, 26 Aug 2004 19:04:35 +1000	[thread overview]
Message-ID: <1093511075.29319.2524.camel@bach> (raw)
In-Reply-To: <200408191750.51863.blaisorblade_spam@yahoo.it>

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


      reply	other threads:[~2004-08-26  9:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-19 15:52 [PATCH] Oops when loading a stripped module BlaisorBlade
2004-08-26  9:04 ` Rusty Russell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1093511075.29319.2524.camel@bach \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@osdl.org \
    --cc=blaisorblade_spam@yahoo.it \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.