From 2aa255b6dde7d7ad5e106a27bc3582cf3933e341 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 5 Jun 2010 11:17:37 -0600 Subject: [PATCH] --- yaml --- r: 200127 b: refs/heads/master c: be593f4ce4eb1bd40e38fdc403371f149f6f12eb h: refs/heads/master i: 200125: 9a175e4d5b80b8d7b99c7c8fe315ae13972f78da 200123: bf2c6577cf4a219607919f08c281d23798debc36 200119: 3297b955b8543a03463e91ce1b10dacdf529f254 200111: 1a7ab326d80033037f780254fe11f660c38f48a8 200095: d78a65a3edaecb577aa970a753713783c4a6629c 200063: 302ff22d61a64f9c9b3a14cab6b4e15f19ceae3f v: v3 --- [refs] | 2 +- trunk/kernel/module.c | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/[refs] b/[refs] index 23ecaf3d01ae..d3890de13094 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3bafeb6247042dcbb72b0141ec7c7107de9f0b99 +refs/heads/master: be593f4ce4eb1bd40e38fdc403371f149f6f12eb diff --git a/trunk/kernel/module.c b/trunk/kernel/module.c index 28450047852a..f99558e1945a 100644 --- a/trunk/kernel/module.c +++ b/trunk/kernel/module.c @@ -1571,6 +1571,8 @@ EXPORT_SYMBOL_GPL(__symbol_get); /* * Ensure that an exported symbol [global namespace] does not already exist * in the kernel or in some other module's exported symbol table. + * + * You must hold the module_mutex. */ static int verify_export_symbols(struct module *mod) { @@ -1592,14 +1594,7 @@ static int verify_export_symbols(struct module *mod) for (i = 0; i < ARRAY_SIZE(arr); i++) { for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) { - const struct kernel_symbol *sym; - - /* Stopping preemption makes find_symbol safe. */ - preempt_disable(); - sym = find_symbol(s->name, &owner, NULL, true, false); - preempt_enable(); - - if (sym) { + if (find_symbol(s->name, &owner, NULL, true, false)) { printk(KERN_ERR "%s: exports duplicate symbol %s" " (owned by %s)\n", @@ -2440,11 +2435,6 @@ static noinline struct module *load_module(void __user *umod, goto cleanup; } - /* Find duplicate symbols */ - err = verify_export_symbols(mod); - if (err < 0) - goto cleanup; - /* Set up and sort exception table */ mod->extable = section_objs(hdr, sechdrs, secstrings, "__ex_table", sizeof(*mod->extable), &mod->num_exentries); @@ -2506,10 +2496,14 @@ static noinline struct module *load_module(void __user *umod, mutex_lock(&module_mutex); if (find_module(mod->name)) { err = -EEXIST; - /* This will also unlock the mutex */ - goto already_exists; + goto unlock; } + /* Find duplicate symbols */ + err = verify_export_symbols(mod); + if (err < 0) + goto unlock; + list_add_rcu(&mod->list, &modules); mutex_unlock(&module_mutex); @@ -2536,7 +2530,7 @@ static noinline struct module *load_module(void __user *umod, mutex_lock(&module_mutex); /* Unlink carefully: kallsyms could be walking list. */ list_del_rcu(&mod->list); - already_exists: + unlock: mutex_unlock(&module_mutex); synchronize_sched(); module_arch_cleanup(mod);