aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/base.c11
-rw-r--r--include/linux/kallsyms.h7
-rw-r--r--include/linux/module.h6
-rw-r--r--kernel/kallsyms.c17
-rw-r--r--kernel/module.c23
-rw-r--r--kernel/time/timer_list.c11
-rw-r--r--kernel/time/timer_stats.c10
7 files changed, 66 insertions, 19 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 3b4fe21c7e94..0c2052c79243 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -278,16 +278,15 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
278 */ 278 */
279static int proc_pid_wchan(struct task_struct *task, char *buffer) 279static int proc_pid_wchan(struct task_struct *task, char *buffer)
280{ 280{
281 const char *sym_name;
282 unsigned long wchan; 281 unsigned long wchan;
283 char namebuf[KSYM_NAME_LEN+1]; 282 char symname[KSYM_NAME_LEN+1];
284 283
285 wchan = get_wchan(task); 284 wchan = get_wchan(task);
286 285
287 sym_name = kallsyms_lookup(wchan, NULL, NULL, NULL, namebuf); 286 if (lookup_symbol_name(wchan, symname) < 0)
288 if (sym_name) 287 return sprintf(buffer, "%lu", wchan);
289 return sprintf(buffer, "%s", sym_name); 288 else
290 return sprintf(buffer, "%lu", wchan); 289 return sprintf(buffer, "%s", symname);
291} 290}
292#endif /* CONFIG_KALLSYMS */ 291#endif /* CONFIG_KALLSYMS */
293 292
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index 3e3b92dabe3b..ae0117a95cfd 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -30,6 +30,8 @@ extern int sprint_symbol(char *buffer, unsigned long address);
30/* Look up a kernel symbol and print it to the kernel messages. */ 30/* Look up a kernel symbol and print it to the kernel messages. */
31extern void __print_symbol(const char *fmt, unsigned long address); 31extern void __print_symbol(const char *fmt, unsigned long address);
32 32
33int lookup_symbol_name(unsigned long addr, char *symname);
34
33#else /* !CONFIG_KALLSYMS */ 35#else /* !CONFIG_KALLSYMS */
34 36
35static inline unsigned long kallsyms_lookup_name(const char *name) 37static inline unsigned long kallsyms_lookup_name(const char *name)
@@ -58,6 +60,11 @@ static inline int sprint_symbol(char *buffer, unsigned long addr)
58 return 0; 60 return 0;
59} 61}
60 62
63static inline int lookup_symbol_name(unsigned long addr, char *symname)
64{
65 return -ERANGE;
66}
67
61/* Stupid that this does nothing, but I didn't create this mess. */ 68/* Stupid that this does nothing, but I didn't create this mess. */
62#define __print_symbol(fmt, addr) 69#define __print_symbol(fmt, addr)
63#endif /*CONFIG_KALLSYMS*/ 70#endif /*CONFIG_KALLSYMS*/
diff --git a/include/linux/module.h b/include/linux/module.h
index 58d5a10cdf0d..099ae5932c68 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -454,6 +454,7 @@ const char *module_address_lookup(unsigned long addr,
454 unsigned long *symbolsize, 454 unsigned long *symbolsize,
455 unsigned long *offset, 455 unsigned long *offset,
456 char **modname); 456 char **modname);
457int lookup_module_symbol_name(unsigned long addr, char *symname);
457 458
458/* For extable.c to search modules' exception tables. */ 459/* For extable.c to search modules' exception tables. */
459const struct exception_table_entry *search_module_extables(unsigned long addr); 460const struct exception_table_entry *search_module_extables(unsigned long addr);
@@ -525,6 +526,11 @@ static inline const char *module_address_lookup(unsigned long addr,
525 return NULL; 526 return NULL;
526} 527}
527 528
529static inline int lookup_module_symbol_name(unsigned long addr, char *symname)
530{
531 return -ERANGE;
532}
533
528static inline int module_get_kallsym(unsigned int symnum, unsigned long *value, 534static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
529 char *type, char *name, 535 char *type, char *name,
530 char *module_name, int *exported) 536 char *module_name, int *exported)
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{
diff --git a/kernel/module.c b/kernel/module.c
index bf4dccadf7b8..3da76ad32d78 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2126,6 +2126,29 @@ const char *module_address_lookup(unsigned long addr,
2126 return NULL; 2126 return NULL;
2127} 2127}
2128 2128
2129int lookup_module_symbol_name(unsigned long addr, char *symname)
2130{
2131 struct module *mod;
2132
2133 mutex_lock(&module_mutex);
2134 list_for_each_entry(mod, &modules, list) {
2135 if (within(addr, mod->module_init, mod->init_size) ||
2136 within(addr, mod->module_core, mod->core_size)) {
2137 const char *sym;
2138
2139 sym = get_ksymbol(mod, addr, NULL, NULL);
2140 if (!sym)
2141 goto out;
2142 strlcpy(symname, sym, KSYM_NAME_LEN + 1);
2143 mutex_unlock(&module_mutex);
2144 return 0;
2145 }
2146 }
2147out:
2148 mutex_unlock(&module_mutex);
2149 return -ERANGE;
2150}
2151
2129int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, 2152int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
2130 char *name, char *module_name, int *exported) 2153 char *name, char *module_name, int *exported)
2131{ 2154{
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);
38 38
39static void print_name_offset(struct seq_file *m, void *sym) 39static void print_name_offset(struct seq_file *m, void *sym)
40{ 40{
41 unsigned long addr = (unsigned long)sym; 41 char symname[KSYM_NAME_LEN+1];
42 char namebuf[KSYM_NAME_LEN+1];
43 const char *sym_name;
44 42
45 sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf); 43 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
46 if (sym_name)
47 SEQ_printf(m, "%s", sym_name);
48 else
49 SEQ_printf(m, "<%p>", sym); 44 SEQ_printf(m, "<%p>", sym);
45 else
46 SEQ_printf(m, "%s", symname);
50} 47}
51 48
52static void 49static void
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index 946ed45f7d2f..868f1bceb07f 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -257,14 +257,12 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
257 257
258static void print_name_offset(struct seq_file *m, unsigned long addr) 258static void print_name_offset(struct seq_file *m, unsigned long addr)
259{ 259{
260 char namebuf[KSYM_NAME_LEN+1]; 260 char symname[KSYM_NAME_LEN+1];
261 const char *sym_name;
262 261
263 sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf); 262 if (lookup_symbol_name(addr, symname) < 0)
264 if (sym_name)
265 seq_printf(m, "%s", sym_name);
266 else
267 seq_printf(m, "<%p>", (void *)addr); 263 seq_printf(m, "<%p>", (void *)addr);
264 else
265 seq_printf(m, "%s", symname);
268} 266}
269 267
270static int tstats_show(struct seq_file *m, void *v) 268static int tstats_show(struct seq_file *m, void *v)