diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-01 21:15:00 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-01 21:15:00 +1000 |
commit | b211104d111c99dbb97c636b57bd9db711455684 (patch) | |
tree | 129d949287a17457f3a8081dd6f04b8a945bcb29 /kernel/module.c | |
parent | 4e2d92454b2d822fe1d474efabccc2a3806d5f86 (diff) | |
download | linux-stable-b211104d111c99dbb97c636b57bd9db711455684.tar.gz linux-stable-b211104d111c99dbb97c636b57bd9db711455684.tar.bz2 linux-stable-b211104d111c99dbb97c636b57bd9db711455684.zip |
module: Enhance verify_export_symbols
Make verify_export_symbols check the modules unused, unused_gpl and
gpl_future syms.
Inspired by Jan Beulich's fix, but table-driven.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/kernel/module.c b/kernel/module.c index ee918938518a..d2d093e74165 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1400,33 +1400,33 @@ EXPORT_SYMBOL_GPL(__symbol_get); */ static int verify_export_symbols(struct module *mod) { - const char *name = NULL; - unsigned long i, ret = 0; + unsigned int i; struct module *owner; - const unsigned long *crc; - - for (i = 0; i < mod->num_syms; i++) - if (!IS_ERR_VALUE(find_symbol(mod->syms[i].name, - &owner, &crc, true, false))) { - name = mod->syms[i].name; - ret = -ENOEXEC; - goto dup; - } + const struct kernel_symbol *s; + struct { + const struct kernel_symbol *sym; + unsigned int num; + } arr[] = { + { mod->syms, mod->num_syms }, + { mod->gpl_syms, mod->num_gpl_syms }, + { mod->gpl_future_syms, mod->num_gpl_future_syms }, + { mod->unused_syms, mod->num_unused_syms }, + { mod->unused_gpl_syms, mod->num_unused_gpl_syms }, + }; - for (i = 0; i < mod->num_gpl_syms; i++) - if (!IS_ERR_VALUE(find_symbol(mod->gpl_syms[i].name, - &owner, &crc, true, false))) { - name = mod->gpl_syms[i].name; - ret = -ENOEXEC; - goto dup; + for (i = 0; i < ARRAY_SIZE(arr); i++) { + for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) { + if (!IS_ERR_VALUE(find_symbol(s->name, &owner, + NULL, true, false))) { + printk(KERN_ERR + "%s: exports duplicate symbol %s" + " (owned by %s)\n", + mod->name, s->name, module_name(owner)); + return -ENOEXEC; + } } - -dup: - if (ret) - printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n", - mod->name, name, module_name(owner)); - - return ret; + } + return 0; } /* Change all symbols so that st_value encodes the pointer directly. */ |