module: make module_address_lookup safe
module_address_lookup releases preemption then returns a pointer into the module space. The only user (kallsyms) copies the result, so just do that under the preempt disable. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@ -2230,14 +2230,13 @@ static const char *get_ksymbol(struct module *mod,
|
||||
return mod->strtab + mod->symtab[best].st_name;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
/* For kallsyms to ask for address resolution. NULL means not found. Careful
|
||||
* not to lock to avoid deadlock on oopses, simply disable preemption. */
|
||||
char *module_address_lookup(unsigned long addr,
|
||||
unsigned long *size,
|
||||
unsigned long *offset,
|
||||
char **modname,
|
||||
char *namebuf)
|
||||
{
|
||||
struct module *mod;
|
||||
const char *ret = NULL;
|
||||
@ -2252,8 +2251,13 @@ const char *module_address_lookup(unsigned long addr,
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Make a copy in here where it's safe */
|
||||
if (ret) {
|
||||
strncpy(namebuf, ret, KSYM_NAME_LEN - 1);
|
||||
ret = namebuf;
|
||||
}
|
||||
preempt_enable();
|
||||
return ret;
|
||||
return (char *)ret;
|
||||
}
|
||||
|
||||
int lookup_module_symbol_name(unsigned long addr, char *symname)
|
||||
|
Reference in New Issue
Block a user