diff options
author | Alexey Dobriyan <adobriyan@sw.ru> | 2007-05-08 00:28:39 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 11:15:08 -0700 |
commit | ea07890a680273b25127129fb555aac0d9324bea (patch) | |
tree | b0742aa5dd90792dc10be3563c1181582d0f5d9e /kernel/module.c | |
parent | ae84e324709d6320ed8c1fd7b1736fcbaf26df95 (diff) | |
download | kernel_samsung_aries-ea07890a680273b25127129fb555aac0d9324bea.zip kernel_samsung_aries-ea07890a680273b25127129fb555aac0d9324bea.tar.gz kernel_samsung_aries-ea07890a680273b25127129fb555aac0d9324bea.tar.bz2 |
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.
[bunk@stusta.de: is_exported() can now become static]
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/module.c b/kernel/module.c index 43a529a..5ee6599 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1472,7 +1472,7 @@ static void setup_modinfo(struct module *mod, Elf_Shdr *sechdrs, } #ifdef CONFIG_KALLSYMS -int is_exported(const char *name, const struct module *mod) +static int is_exported(const char *name, const struct module *mod) { if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab)) return 1; @@ -2124,8 +2124,8 @@ const char *module_address_lookup(unsigned long addr, return NULL; } -struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, - char *type, char *name) +int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, + char *name, char *module_name, int *exported) { struct module *mod; @@ -2136,13 +2136,15 @@ struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, *type = mod->symtab[symnum].st_info; strlcpy(name, mod->strtab + mod->symtab[symnum].st_name, KSYM_NAME_LEN + 1); + strlcpy(module_name, mod->name, MODULE_NAME_LEN + 1); + *exported = is_exported(name, mod); mutex_unlock(&module_mutex); - return mod; + return 0; } symnum -= mod->num_symtab; } mutex_unlock(&module_mutex); - return NULL; + return -ERANGE; } static unsigned long mod_find_symname(struct module *mod, const char *name) |