diff options
author | Alexey Dobriyan <adobriyan@sw.ru> | 2007-05-08 00:28:43 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 11:15:08 -0700 |
commit | 9d65cb4a1718a072898c7a57a3bc61b2dc4bcd4d (patch) | |
tree | 9e3fd1c9e61e8ed16959d115a9a3f6f7eb0bbf21 /kernel/time/timer_list.c | |
parent | ffb45122766db220d0bf3d01848d575fbbcb6430 (diff) | |
download | linux-9d65cb4a1718a072898c7a57a3bc61b2dc4bcd4d.tar.gz linux-9d65cb4a1718a072898c7a57a3bc61b2dc4bcd4d.tar.bz2 linux-9d65cb4a1718a072898c7a57a3bc61b2dc4bcd4d.zip |
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/time/timer_list.c')
-rw-r--r-- | kernel/time/timer_list.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c index fe9314a89f20..b734ca4bc75e 100644 --- a/kernel/time/timer_list.c +++ b/kernel/time/timer_list.c @@ -38,15 +38,12 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases); static void print_name_offset(struct seq_file *m, void *sym) { - unsigned long addr = (unsigned long)sym; - char namebuf[KSYM_NAME_LEN+1]; - const char *sym_name; + char symname[KSYM_NAME_LEN+1]; - sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf); - if (sym_name) - SEQ_printf(m, "%s", sym_name); - else + if (lookup_symbol_name((unsigned long)sym, symname) < 0) SEQ_printf(m, "<%p>", sym); + else + SEQ_printf(m, "%s", symname); } static void |