Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bb9d3d56e792d2619cc0903df4ac01d86ac1261d
Commit:     bb9d3d56e792d2619cc0903df4ac01d86ac1261d
Parent:     efa5345e39d01deef349c120f55ac6b6eabe7457
Author:     Rusty Russell <[EMAIL PROTECTED]>
AuthorDate: Tue Jan 29 17:13:21 2008 -0500
Committer:  Rusty Russell <[EMAIL PROTECTED]>
CommitDate: Tue Jan 29 17:13:22 2008 +1100

    module: better OOPS and lockdep coverage for loading modules
    
    If we put the module in the linked list *before* calling into to, we
    get the module name and functions in the OOPS (is_module_address can
    find the module).  It also helps lockdep in a similar way.
    
    Acked-and-tested-by: Joern Engel <[EMAIL PROTECTED]>
    Tested-by: Erez Zadok <[EMAIL PROTECTED]>
    Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
---
 kernel/module.c |   38 ++++++++++++++++++++------------------
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 276abd7..12067ff 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1294,6 +1294,17 @@ static void mod_kobject_remove(struct module *mod)
 }
 
 /*
+ * link the module with the whole machine is stopped with interrupts off
+ * - this defends against kallsyms not taking locks
+ */
+static int __link_module(void *_mod)
+{
+       struct module *mod = _mod;
+       list_add(&mod->list, &modules);
+       return 0;
+}
+
+/*
  * unlink the module with the whole machine is stopped with interrupts off
  * - this defends against kallsyms not taking locks
  */
@@ -2035,6 +2046,11 @@ static struct module *load_module(void __user *umod,
                printk(KERN_WARNING "%s: Ignoring obsolete parameters\n",
                       mod->name);
 
+       /* Now sew it into the lists so we can get lockdep and oops
+         * info during argument parsing.  Noone should access us, since
+         * strong_try_module_get() will fail. */
+       stop_machine_run(__link_module, mod, NR_CPUS);
+
        /* Size of section 0 is 0, so this works well if no params */
        err = parse_args(mod->name, mod->args,
                         (struct kernel_param *)
@@ -2043,7 +2059,7 @@ static struct module *load_module(void __user *umod,
                         / sizeof(struct kernel_param),
                         NULL);
        if (err < 0)
-               goto arch_cleanup;
+               goto unlink;
 
        err = mod_sysfs_setup(mod,
                              (struct kernel_param *)
@@ -2051,7 +2067,7 @@ static struct module *load_module(void __user *umod,
                              sechdrs[setupindex].sh_size
                              / sizeof(struct kernel_param));
        if (err < 0)
-               goto arch_cleanup;
+               goto unlink;
        add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
        add_notes_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
 
@@ -2066,7 +2082,8 @@ static struct module *load_module(void __user *umod,
        /* Done! */
        return mod;
 
- arch_cleanup:
+ unlink:
+       stop_machine_run(__unlink_module, mod, NR_CPUS);
        module_arch_cleanup(mod);
  cleanup:
        kobject_del(&mod->mkobj.kobj);
@@ -2091,17 +2108,6 @@ static struct module *load_module(void __user *umod,
        goto free_hdr;
 }
 
-/*
- * link the module with the whole machine is stopped with interrupts off
- * - this defends against kallsyms not taking locks
- */
-static int __link_module(void *_mod)
-{
-       struct module *mod = _mod;
-       list_add(&mod->list, &modules);
-       return 0;
-}
-
 /* This is where the real work happens */
 asmlinkage long
 sys_init_module(void __user *umod,
@@ -2126,10 +2132,6 @@ sys_init_module(void __user *umod,
                return PTR_ERR(mod);
        }
 
-       /* Now sew it into the lists.  They won't access us, since
-           strong_try_module_get() will fail. */
-       stop_machine_run(__link_module, mod, NR_CPUS);
-
        /* Drop lock so they can recurse */
        mutex_unlock(&module_mutex);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to