linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix use-after-free when trying to load an invalid module
@ 2003-06-14 12:08 Luca Barbieri
  2003-06-15  1:00 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Luca Barbieri @ 2003-06-14 12:08 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux-Kernel ML, rusty

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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix use-after-free when trying to load an invalid module
  2003-06-14 12:08 [PATCH] Fix use-after-free when trying to load an invalid module Luca Barbieri
@ 2003-06-15  1:00 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2003-06-15  1:00 UTC (permalink / raw)
  To: Luca Barbieri; +Cc: Linux-Kernel ML

In message <1055592512.3810.12.camel@home.lb.ods.org> you write:
> 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.

Thanks for the fix!  This was fixed another way, though, in Linus'
tree.

Thanks,
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-06-15  1:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-14 12:08 [PATCH] Fix use-after-free when trying to load an invalid module Luca Barbieri
2003-06-15  1:00 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).