提交 b211104d 编写于 作者: R Rusty Russell

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: NRusty Russell <rusty@rustcorp.com.au>
上级 4e2d9245
...@@ -1400,33 +1400,33 @@ EXPORT_SYMBOL_GPL(__symbol_get); ...@@ -1400,33 +1400,33 @@ EXPORT_SYMBOL_GPL(__symbol_get);
*/ */
static int verify_export_symbols(struct module *mod) static int verify_export_symbols(struct module *mod)
{ {
const char *name = NULL; unsigned int i;
unsigned long i, ret = 0;
struct module *owner; struct module *owner;
const unsigned long *crc; const struct kernel_symbol *s;
struct {
for (i = 0; i < mod->num_syms; i++) const struct kernel_symbol *sym;
if (!IS_ERR_VALUE(find_symbol(mod->syms[i].name, unsigned int num;
&owner, &crc, true, false))) { } arr[] = {
name = mod->syms[i].name; { mod->syms, mod->num_syms },
ret = -ENOEXEC; { mod->gpl_syms, mod->num_gpl_syms },
goto dup; { 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++) for (i = 0; i < ARRAY_SIZE(arr); i++) {
if (!IS_ERR_VALUE(find_symbol(mod->gpl_syms[i].name, for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
&owner, &crc, true, false))) { if (!IS_ERR_VALUE(find_symbol(s->name, &owner,
name = mod->gpl_syms[i].name; NULL, true, false))) {
ret = -ENOEXEC; printk(KERN_ERR
goto dup; "%s: exports duplicate symbol %s"
" (owned by %s)\n",
mod->name, s->name, module_name(owner));
return -ENOEXEC;
}
} }
}
dup: return 0;
if (ret)
printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
mod->name, name, module_name(owner));
return ret;
} }
/* Change all symbols so that st_value encodes the pointer directly. */ /* Change all symbols so that st_value encodes the pointer directly. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册