mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
Fix race between rmmod and cat /proc/kallsyms
module_get_kallsym() leaks "struct module *" outside of module_mutex which is no-no, because module can dissapear right after mutex unlock. Copy all needed information from inside module_mutex into caller-supplied space. [[email protected]: is_exported() can now become static] Signed-off-by: Alexey Dobriyan <[email protected]> Cc: Rusty Russell <[email protected]> Signed-off-by: Adrian Bunk <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
ae84e32470
commit
ea07890a68
3 changed files with 29 additions and 34 deletions
|
|
@ -301,25 +301,20 @@ void __print_symbol(const char *fmt, unsigned long address)
|
|||
struct kallsym_iter
|
||||
{
|
||||
loff_t pos;
|
||||
struct module *owner;
|
||||
unsigned long value;
|
||||
unsigned int nameoff; /* If iterating in core kernel symbols */
|
||||
char type;
|
||||
char name[KSYM_NAME_LEN+1];
|
||||
char module_name[MODULE_NAME_LEN + 1];
|
||||
int exported;
|
||||
};
|
||||
|
||||
static int get_ksymbol_mod(struct kallsym_iter *iter)
|
||||
{
|
||||
iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms,
|
||||
&iter->value, &iter->type,
|
||||
iter->name);
|
||||
if (iter->owner == NULL)
|
||||
if (module_get_kallsym(iter->pos - kallsyms_num_syms, &iter->value,
|
||||
&iter->type, iter->name, iter->module_name,
|
||||
&iter->exported) < 0)
|
||||
return 0;
|
||||
|
||||
/* Label it "global" if it is exported, "local" if not exported. */
|
||||
iter->type = is_exported(iter->name, iter->owner)
|
||||
? toupper(iter->type) : tolower(iter->type);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -328,7 +323,7 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
|
|||
{
|
||||
unsigned off = iter->nameoff;
|
||||
|
||||
iter->owner = NULL;
|
||||
iter->module_name[0] = '\0';
|
||||
iter->value = kallsyms_addresses[iter->pos];
|
||||
|
||||
iter->type = kallsyms_get_symbol_type(off);
|
||||
|
|
@ -392,12 +387,17 @@ static int s_show(struct seq_file *m, void *p)
|
|||
if (!iter->name[0])
|
||||
return 0;
|
||||
|
||||
if (iter->owner)
|
||||
if (iter->module_name[0]) {
|
||||
char type;
|
||||
|
||||
/* Label it "global" if it is exported,
|
||||
* "local" if not exported. */
|
||||
type = iter->exported ? toupper(iter->type) :
|
||||
tolower(iter->type);
|
||||
seq_printf(m, "%0*lx %c %s\t[%s]\n",
|
||||
(int)(2*sizeof(void*)),
|
||||
iter->value, iter->type, iter->name,
|
||||
module_name(iter->owner));
|
||||
else
|
||||
iter->value, type, iter->name, iter->module_name);
|
||||
} else
|
||||
seq_printf(m, "%0*lx %c %s\n",
|
||||
(int)(2*sizeof(void*)),
|
||||
iter->value, iter->type, iter->name);
|
||||
|
|
|
|||
Loading…
Reference in a new issue