aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kallsyms.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@sw.ru>2007-05-08 03:28:43 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:08 -0400
commit9d65cb4a1718a072898c7a57a3bc61b2dc4bcd4d (patch)
tree9e3fd1c9e61e8ed16959d115a9a3f6f7eb0bbf21 /kernel/kallsyms.c
parentffb45122766db220d0bf3d01848d575fbbcb6430 (diff)
Fix race between cat /proc/*/wchan and rmmod et al
kallsyms_lookup() can go iterating over modules list unprotected which is OK for emergency situations (oops), but not OK for regular stuff like /proc/*/wchan. Introduce lookup_symbol_name()/lookup_module_symbol_name() which copy symbol name into caller-supplied buffer or return -ERANGE. All copying is done with module_mutex held, so... Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Cc: 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/kallsyms.c')
-rw-r--r--kernel/kallsyms.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index f66da025cb7f..4e2ec191a127 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -269,6 +269,23 @@ const char *kallsyms_lookup(unsigned long addr,
269 return NULL; 269 return NULL;
270} 270}
271 271
272int lookup_symbol_name(unsigned long addr, char *symname)
273{
274 symname[0] = '\0';
275 symname[KSYM_NAME_LEN] = '\0';
276
277 if (is_ksym_addr(addr)) {
278 unsigned long pos;
279
280 pos = get_symbol_pos(addr, NULL, NULL);
281 /* Grab name */
282 kallsyms_expand_symbol(get_symbol_offset(pos), symname);
283 return 0;
284 }
285 /* see if it's in a module */
286 return lookup_module_symbol_name(addr, symname);
287}
288
272/* Look up a kernel symbol and return it in a text buffer. */ 289/* Look up a kernel symbol and return it in a text buffer. */
273int sprint_symbol(char *buffer, unsigned long address) 290int sprint_symbol(char *buffer, unsigned long address)
274{ 291{