From: Luca Barbieri <lb@lb.ods.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Linux-Kernel ML <linux-kernel@vger.kernel.org>, rusty@rustcorp.com.au
Subject: [PATCH] Fix use-after-free when trying to load an invalid module
Date: 14 Jun 2003 14:08:32 +0200 [thread overview]
Message-ID: <1055592512.3810.12.camel@home.lb.ods.org> (raw)
mod->module_core contains the mod structure, so it must be freed after
mod->percpu.
However, initialization happens in the opposite order because mod is
moved after that, so we need to initialize module_core to 0 and check it
later.
--- linux-2.5.70/kernel/module.c~ 2003-06-02 10:50:57.000000000 +0200
+++ linux-2.5.70/kernel/module.c 2003-06-11 18:08:47.000000000 +0200
@@ -1417,6 +1417,7 @@ static struct module *load_module(void _
if (err < 0)
goto free_mod;
+ mod->module_core = NULL;
if (pcpuindex) {
/* We have a special allocation for this section. */
mod->percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size,
@@ -1565,10 +1566,12 @@ static struct module *load_module(void _
module_unload_free(mod);
module_free(mod, mod->module_init);
free_core:
- module_free(mod, mod->module_core);
free_percpu:
if (mod->percpu)
percpu_modfree(mod->percpu);
+
+ if(mod->module_core)
+ module_free(mod, mod->module_core);
free_mod:
kfree(args);
free_hdr:
--
Luca Barbieri <lb@lb.ods.org>
next reply other threads:[~2003-06-14 11:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-14 12:08 Luca Barbieri [this message]
2003-06-15 1:00 ` 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=1055592512.3810.12.camel@home.lb.ods.org \
--to=lb@lb.ods.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@transmeta.com \
/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
all inboxes | Powered by JetHome®