Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 75442
b: refs/heads/master
c: cb2a520
h: refs/heads/master
v: v3
  • Loading branch information
Rusty Russell authored and Linus Torvalds committed Jan 14, 2008
1 parent 4e22abc commit 7d26960
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1a1b285c24e1468afe82b09330dde5192a6e0013
refs/heads/master: cb2a52052cebe4716e83b9d2e53682ba00f67de6
29 changes: 18 additions & 11 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2214,29 +2214,34 @@ static const char *get_ksymbol(struct module *mod,
/* For kallsyms to ask for address resolution. NULL means not found.
We don't lock, as this is used for oops resolution and races are a
lesser concern. */
/* FIXME: Risky: returns a pointer into a module w/o lock */
const char *module_address_lookup(unsigned long addr,
unsigned long *size,
unsigned long *offset,
char **modname)
{
struct module *mod;
const char *ret = NULL;

preempt_disable();
list_for_each_entry(mod, &modules, list) {
if (within(addr, mod->module_init, mod->init_size)
|| within(addr, mod->module_core, mod->core_size)) {
if (modname)
*modname = mod->name;
return get_ksymbol(mod, addr, size, offset);
ret = get_ksymbol(mod, addr, size, offset);
break;
}
}
return NULL;
preempt_enable();
return ret;
}

int lookup_module_symbol_name(unsigned long addr, char *symname)
{
struct module *mod;

mutex_lock(&module_mutex);
preempt_disable();
list_for_each_entry(mod, &modules, list) {
if (within(addr, mod->module_init, mod->init_size) ||
within(addr, mod->module_core, mod->core_size)) {
Expand All @@ -2246,12 +2251,12 @@ int lookup_module_symbol_name(unsigned long addr, char *symname)
if (!sym)
goto out;
strlcpy(symname, sym, KSYM_NAME_LEN);
mutex_unlock(&module_mutex);
preempt_enable();
return 0;
}
}
out:
mutex_unlock(&module_mutex);
preempt_enable();
return -ERANGE;
}

Expand All @@ -2260,7 +2265,7 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
{
struct module *mod;

mutex_lock(&module_mutex);
preempt_disable();
list_for_each_entry(mod, &modules, list) {
if (within(addr, mod->module_init, mod->init_size) ||
within(addr, mod->module_core, mod->core_size)) {
Expand All @@ -2273,12 +2278,12 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
strlcpy(modname, mod->name, MODULE_NAME_LEN);
if (name)
strlcpy(name, sym, KSYM_NAME_LEN);
mutex_unlock(&module_mutex);
preempt_enable();
return 0;
}
}
out:
mutex_unlock(&module_mutex);
preempt_enable();
return -ERANGE;
}

Expand All @@ -2287,7 +2292,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
{
struct module *mod;

mutex_lock(&module_mutex);
preempt_disable();
list_for_each_entry(mod, &modules, list) {
if (symnum < mod->num_symtab) {
*value = mod->symtab[symnum].st_value;
Expand All @@ -2296,12 +2301,12 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
KSYM_NAME_LEN);
strlcpy(module_name, mod->name, MODULE_NAME_LEN);
*exported = is_exported(name, mod);
mutex_unlock(&module_mutex);
preempt_enable();
return 0;
}
symnum -= mod->num_symtab;
}
mutex_unlock(&module_mutex);
preempt_enable();
return -ERANGE;
}

Expand All @@ -2324,6 +2329,7 @@ unsigned long module_kallsyms_lookup_name(const char *name)
unsigned long ret = 0;

/* Don't lock: we're in enough trouble already. */
preempt_disable();
if ((colon = strchr(name, ':')) != NULL) {
*colon = '\0';
if ((mod = find_module(name)) != NULL)
Expand All @@ -2334,6 +2340,7 @@ unsigned long module_kallsyms_lookup_name(const char *name)
if ((ret = mod_find_symname(mod, name)) != 0)
break;
}
preempt_enable();
return ret;
}
#endif /* CONFIG_KALLSYMS */
Expand Down

0 comments on commit 7d26960

Please sign in to comment.