aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@sw.ru>2007-05-08 03:28:47 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:08 -0400
commita5c43dae7ae38c2a6b3e9a819bcf45f010bf6a4a (patch)
treeb30da7a4541e803e35a6a74ad33e836442c3f6c8 /kernel
parent9d65cb4a1718a072898c7a57a3bc61b2dc4bcd4d (diff)
Fix race between cat /proc/slab_allocators and rmmod
Same story as with cat /proc/*/wchan race vs rmmod race, only /proc/slab_allocators want more info than just symbol name. Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kallsyms.c19
-rw-r--r--kernel/module.c27
2 files changed, 46 insertions, 0 deletions
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 4e2ec191a127..c36581b40c04 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -286,6 +286,25 @@ int lookup_symbol_name(unsigned long addr, char *symname)
286 return lookup_module_symbol_name(addr, symname); 286 return lookup_module_symbol_name(addr, symname);
287} 287}
288 288
289int lookup_symbol_attrs(unsigned long addr, unsigned long *size,
290 unsigned long *offset, char *modname, char *name)
291{
292 name[0] = '\0';
293 name[KSYM_NAME_LEN] = '\0';
294
295 if (is_ksym_addr(addr)) {
296 unsigned long pos;
297
298 pos = get_symbol_pos(addr, size, offset);
299 /* Grab name */
300 kallsyms_expand_symbol(get_symbol_offset(pos), name);
301 modname[0] = '\0';
302 return 0;
303 }
304 /* see if it's in a module */
305 return lookup_module_symbol_attrs(addr, size, offset, modname, name);
306}
307
289/* Look up a kernel symbol and return it in a text buffer. */ 308/* Look up a kernel symbol and return it in a text buffer. */
290int sprint_symbol(char *buffer, unsigned long address) 309int sprint_symbol(char *buffer, unsigned long address)
291{ 310{
diff --git a/kernel/module.c b/kernel/module.c
index 3da76ad32d78..d36e45477fac 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2149,6 +2149,33 @@ out:
2149 return -ERANGE; 2149 return -ERANGE;
2150} 2150}
2151 2151
2152int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
2153 unsigned long *offset, char *modname, char *name)
2154{
2155 struct module *mod;
2156
2157 mutex_lock(&module_mutex);
2158 list_for_each_entry(mod, &modules, list) {
2159 if (within(addr, mod->module_init, mod->init_size) ||
2160 within(addr, mod->module_core, mod->core_size)) {
2161 const char *sym;
2162
2163 sym = get_ksymbol(mod, addr, size, offset);
2164 if (!sym)
2165 goto out;
2166 if (modname)
2167 strlcpy(modname, mod->name, MODULE_NAME_LEN + 1);
2168 if (name)
2169 strlcpy(name, sym, KSYM_NAME_LEN + 1);
2170 mutex_unlock(&module_mutex);
2171 return 0;
2172 }
2173 }
2174out:
2175 mutex_unlock(&module_mutex);
2176 return -ERANGE;
2177}
2178
2152int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, 2179int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
2153 char *name, char *module_name, int *exported) 2180 char *name, char *module_name, int *exported)
2154{ 2181{