aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kallsyms.c1
-rw-r--r--kernel/kprobes.c26
2 files changed, 26 insertions, 1 deletions
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index ab16a5a4cfe9..342bca62c496 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -154,7 +154,6 @@ unsigned long kallsyms_lookup_name(const char *name)
154 } 154 }
155 return module_kallsyms_lookup_name(name); 155 return module_kallsyms_lookup_name(name);
156} 156}
157EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
158 157
159/* 158/*
160 * Lookup an address 159 * Lookup an address
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 3f57dfdc8f92..f66b8e681b4d 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -37,6 +37,7 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/moduleloader.h> 39#include <linux/moduleloader.h>
40#include <linux/kallsyms.h>
40#include <asm-generic/sections.h> 41#include <asm-generic/sections.h>
41#include <asm/cacheflush.h> 42#include <asm/cacheflush.h>
42#include <asm/errno.h> 43#include <asm/errno.h>
@@ -45,6 +46,16 @@
45#define KPROBE_HASH_BITS 6 46#define KPROBE_HASH_BITS 6
46#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) 47#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
47 48
49
50/*
51 * Some oddball architectures like 64bit powerpc have function descriptors
52 * so this must be overridable.
53 */
54#ifndef kprobe_lookup_name
55#define kprobe_lookup_name(name, addr) \
56 addr = ((kprobe_opcode_t *)(kallsyms_lookup_name(name)))
57#endif
58
48static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE]; 59static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
49static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE]; 60static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE];
50static atomic_t kprobe_count; 61static atomic_t kprobe_count;
@@ -447,6 +458,21 @@ static int __kprobes __register_kprobe(struct kprobe *p,
447 struct kprobe *old_p; 458 struct kprobe *old_p;
448 struct module *probed_mod; 459 struct module *probed_mod;
449 460
461 /*
462 * If we have a symbol_name argument look it up,
463 * and add it to the address. That way the addr
464 * field can either be global or relative to a symbol.
465 */
466 if (p->symbol_name) {
467 if (p->addr)
468 return -EINVAL;
469 kprobe_lookup_name(p->symbol_name, p->addr);
470 }
471
472 if (!p->addr)
473 return -EINVAL;
474 p->addr = (kprobe_opcode_t *)(((char *)p->addr)+ p->offset);
475
450 if ((!kernel_text_address((unsigned long) p->addr)) || 476 if ((!kernel_text_address((unsigned long) p->addr)) ||
451 in_kprobes_functions((unsigned long) p->addr)) 477 in_kprobes_functions((unsigned long) p->addr))
452 return -EINVAL; 478 return -EINVAL;