diff options
author | Alexey Dobriyan <adobriyan@sw.ru> | 2007-05-08 11:28:39 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 22:15:08 +0400 |
commit | ea07890a680273b25127129fb555aac0d9324bea (patch) | |
tree | b0742aa5dd90792dc10be3563c1181582d0f5d9e /include/linux/module.h | |
parent | ae84e324709d6320ed8c1fd7b1736fcbaf26df95 (diff) | |
download | linux-ea07890a680273b25127129fb555aac0d9324bea.tar.xz |
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 'include/linux/module.h')
-rw-r--r-- | include/linux/module.h | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index 799930216626..58d5a10cdf0d 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -370,16 +370,14 @@ struct module *module_text_address(unsigned long addr); struct module *__module_text_address(unsigned long addr); int is_module_address(unsigned long addr); -/* Returns module and fills in value, defined and namebuf, or NULL if +/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if symnum out of range. */ -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); /* Look for this name: can be of form module:name. */ unsigned long module_kallsyms_lookup_name(const char *name); -int is_exported(const char *name, const struct module *mod); - extern void __module_put_and_exit(struct module *mod, long code) __attribute__((noreturn)); #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); @@ -527,11 +525,11 @@ static inline const char *module_address_lookup(unsigned long addr, return NULL; } -static inline struct module *module_get_kallsym(unsigned int symnum, - unsigned long *value, - char *type, char *name) +static inline int module_get_kallsym(unsigned int symnum, unsigned long *value, + char *type, char *name, + char *module_name, int *exported) { - return NULL; + return -ERANGE; } static inline unsigned long module_kallsyms_lookup_name(const char *name) @@ -539,11 +537,6 @@ static inline unsigned long module_kallsyms_lookup_name(const char *name) return 0; } -static inline int is_exported(const char *name, const struct module *mod) -{ - return 0; -} - static inline int register_module_notifier(struct notifier_block * nb) { /* no events will happen anyway, so this can always succeed */ |