From: Ashutosh Naik <ashutosh.naik@gmail.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andrew Morton <akpm@osdl.org>,
jesper.juhl@gmail.com, anandhkrishnan@yahoo.co.in,
linux-kernel@vger.kernel.org, rth@redhat.com, greg@kroah.com,
alan@lxorguk.ukuu.org.uk, kaos@ocs.com.au
Subject: Re: [RFC][PATCH] Prevent overriding of Symbols in the Kernel, avoiding Undefined behaviour
Date: Thu, 15 Dec 2005 11:15:40 +0530 [thread overview]
Message-ID: <81083a450512142145u56075dfch16ae708f34d93e7c@mail.gmail.com> (raw)
In-Reply-To: <1134623704.7773.34.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
On 12/15/05, Rusty Russell <rusty@rustcorp.com.au> wrote:
> On Wed, 2005-12-14 at 20:40 -0800, Andrew Morton wrote:
> + if (!__find_symbol(mod->syms[i].name, &owner, &crc, 1)) {
if (__find_symbol(mod->syms[i].name, &owner, &crc, 1)) {
>+ if (!__find_symbol(mod->gpl_syms[i].name, &owner, &crc, 1)) {
if (__find_symbol(mod->gpl_syms[i].name, &owner, &crc, 1)) {
Oops... I dunno how we missed it
This code is architecture independent.
Changelog -
This patch ensures that an exported symbol does not already exist in
the kernel or in some other module's exported symbol table. This is
done by checking the symbol tables for the exported symbol at the time
of loading the module. Currently this is done after the relocation of
the symbol.
Signed-off-by: Ashutosh Naik <ashutosh.naik@gmail.com>
Signed-off-by: Anand Krishnan <anandhkrishnan@yahoo.co.in>
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1710 bytes --]
diff -Naurp linux-2.6.15-rc5-vanilla/kernel/module.c linux-2.6.15-rc5/kernel/module.c
--- linux-2.6.15-rc5-vanilla/kernel/module.c 2005-12-14 10:14:08.000000000 +0530
+++ linux-2.6.15-rc5/kernel/module.c 2005-12-15 11:01:17.000000000 +0530
@@ -1204,6 +1204,39 @@ void *__symbol_get(const char *symbol)
}
EXPORT_SYMBOL_GPL(__symbol_get);
+/*
+ * Ensure that an exported symbol [global namespace] does not already exist
+ * in the Kernel or in some other modules exported symbol table.
+ */
+static int verify_export_symbols(struct module *mod)
+{
+ const char *name = NULL;
+ unsigned long i, ret = 0;
+ struct module *owner;
+ const unsigned long *crc;
+
+ for (i = 0; i < mod->num_syms; i++)
+ if (__find_symbol(mod->syms[i].name, &owner, &crc, 1)) {
+ name = mod->syms[i].name;
+ ret = -ENOEXEC;
+ goto dup;
+ }
+
+ for (i = 0; i < mod->num_gpl_syms; i++)
+ if (__find_symbol(mod->gpl_syms[i].name, &owner, &crc, 1)) {
+ name = mod->gpl_syms[i].name;
+ ret = -ENOEXEC;
+ goto dup;
+ }
+
+dup:
+ if (ret)
+ printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
+ mod->name, name, module_name(owner));
+
+ return ret;
+}
+
/* Change all symbols so that sh_value encodes the pointer directly. */
static int simplify_symbols(Elf_Shdr *sechdrs,
unsigned int symindex,
@@ -1767,6 +1800,12 @@ static struct module *load_module(void _
goto cleanup;
}
+ /* Find duplicate symbols */
+ err = verify_export_symbols(mod);
+
+ if (err < 0)
+ goto cleanup;
+
/* Set up and sort exception table */
mod->num_exentries = sechdrs[exindex].sh_size / sizeof(*mod->extable);
mod->extable = extable = (void *)sechdrs[exindex].sh_addr;
next prev parent reply other threads:[~2005-12-16 2:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-12 12:39 Ashutosh Naik
2005-12-12 12:44 ` Ashutosh Naik
2005-12-12 22:25 ` Jesper Juhl
2005-12-13 8:23 ` Anand H. Krishnan
2005-12-12 19:13 ` Andrew Morton
2005-12-12 19:27 ` Richard Henderson
2005-12-12 20:20 ` Greg KH
2005-12-12 20:30 ` Jesper Juhl
2005-12-12 22:48 ` Alan Cox
2005-12-13 8:03 ` Arjan van de Ven
2005-12-13 14:32 ` Ashutosh Naik
2005-12-12 22:01 ` Rusty Russell
2005-12-13 14:26 ` Ashutosh Naik
2005-12-13 15:28 ` Ashutosh Naik
2005-12-13 16:49 ` [RFC][PATCH] " Jesper Juhl
2005-12-14 2:03 ` Rusty Russell
2005-12-14 4:10 ` Ashutosh Naik
2005-12-14 5:02 ` Ashutosh Naik
2005-12-15 4:40 ` Andrew Morton
2005-12-15 5:15 ` Rusty Russell
2005-12-15 5:45 ` Ashutosh Naik [this message]
2005-12-14 5:46 ` Ashutosh Naik
2005-12-14 23:02 ` Rusty Russell
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=81083a450512142145u56075dfch16ae708f34d93e7c@mail.gmail.com \
--to=ashutosh.naik@gmail.com \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=anandhkrishnan@yahoo.co.in \
--cc=greg@kroah.com \
--cc=jesper.juhl@gmail.com \
--cc=kaos@ocs.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=rth@redhat.com \
--cc=rusty@rustcorp.com.au \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome