Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 17007
b: refs/heads/master
c: eea8b54
h: refs/heads/master
i:
  17005: cc50c14
  17003: d882243
  16999: 98aa08f
  16991: 54619c1
v: v3
  • Loading branch information
Ashutosh Naik authored and Linus Torvalds committed Jan 9, 2006
1 parent 5d5a31f commit ba66f4a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b368fae6abaa1736b8f26128c32947d47237b8e5
refs/heads/master: eea8b54dc0dceb740da697a89c54d20dde340306
39 changes: 39 additions & 0 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,39 @@ void *__symbol_get(const char *symbol)
}
EXPORT_SYMBOL_GPL(__symbol_get);

/*
* Ensure that an exported symbol [global namespace] does not already exist
* in the Kernel or in some other modules exported symbol table.
*/
static int verify_export_symbols(struct module *mod)
{
const char *name = NULL;
unsigned long i, ret = 0;
struct module *owner;
const unsigned long *crc;

for (i = 0; i < mod->num_syms; i++)
if (__find_symbol(mod->syms[i].name, &owner, &crc, 1)) {
name = mod->syms[i].name;
ret = -ENOEXEC;
goto dup;
}

for (i = 0; i < mod->num_gpl_syms; i++)
if (__find_symbol(mod->gpl_syms[i].name, &owner, &crc, 1)) {
name = mod->gpl_syms[i].name;
ret = -ENOEXEC;
goto dup;
}

dup:
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 sh_value encodes the pointer directly. */
static int simplify_symbols(Elf_Shdr *sechdrs,
unsigned int symindex,
Expand Down Expand Up @@ -1772,6 +1805,12 @@ static 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->num_exentries = sechdrs[exindex].sh_size / sizeof(*mod->extable);
mod->extable = extable = (void *)sechdrs[exindex].sh_addr;
Expand Down

0 comments on commit ba66f4a

Please sign in to comment.