diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2010-02-02 16:49:18 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-02-04 03:36:19 -0500 |
commit | 4554dbcb85a4ed2abaa2b6fa15649b796699ec89 (patch) | |
tree | 5debd228bf382384d8a1430246b65a0f669f816f | |
parent | 2cfa19780d61740f65790c5bae363b759d7c96fa (diff) |
kprobes: Check probe address is reserved
Check whether the address of new probe is already reserved by
ftrace or alternatives (on x86) when registering new probe.
If reserved, it returns an error and not register the probe.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: przemyslaw@pawelczyk.it
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Mathieu Desnoyers <compudj@krystal.dyndns.org>
Cc: Jason Baron <jbaron@redhat.com>
LKML-Reference: <20100202214918.4694.94179.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/kernel/kprobes.c | 3 | ||||
-rw-r--r-- | kernel/kprobes.c | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c index 9453815138fa..5de9f4a9c3fd 100644 --- a/arch/x86/kernel/kprobes.c +++ b/arch/x86/kernel/kprobes.c | |||
@@ -337,6 +337,9 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p) | |||
337 | 337 | ||
338 | int __kprobes arch_prepare_kprobe(struct kprobe *p) | 338 | int __kprobes arch_prepare_kprobe(struct kprobe *p) |
339 | { | 339 | { |
340 | if (alternatives_text_reserved(p->addr, p->addr)) | ||
341 | return -EINVAL; | ||
342 | |||
340 | if (!can_probe((unsigned long)p->addr)) | 343 | if (!can_probe((unsigned long)p->addr)) |
341 | return -EILSEQ; | 344 | return -EILSEQ; |
342 | /* insn: must be on special executable page on x86. */ | 345 | /* insn: must be on special executable page on x86. */ |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 9907a03c29f6..c3340e836c37 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/debugfs.h> | 44 | #include <linux/debugfs.h> |
45 | #include <linux/kdebug.h> | 45 | #include <linux/kdebug.h> |
46 | #include <linux/memory.h> | 46 | #include <linux/memory.h> |
47 | #include <linux/ftrace.h> | ||
47 | 48 | ||
48 | #include <asm-generic/sections.h> | 49 | #include <asm-generic/sections.h> |
49 | #include <asm/cacheflush.h> | 50 | #include <asm/cacheflush.h> |
@@ -703,7 +704,8 @@ int __kprobes register_kprobe(struct kprobe *p) | |||
703 | 704 | ||
704 | preempt_disable(); | 705 | preempt_disable(); |
705 | if (!kernel_text_address((unsigned long) p->addr) || | 706 | if (!kernel_text_address((unsigned long) p->addr) || |
706 | in_kprobes_functions((unsigned long) p->addr)) { | 707 | in_kprobes_functions((unsigned long) p->addr) || |
708 | ftrace_text_reserved(p->addr, p->addr)) { | ||
707 | preempt_enable(); | 709 | preempt_enable(); |
708 | return -EINVAL; | 710 | return -EINVAL; |
709 | } | 711 | } |