Selaa lähdekoodia

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>
Masami Hiramatsu 15 vuotta sitten
vanhempi
commit
4554dbcb85
2 muutettua tiedostoa jossa 6 lisäystä ja 1 poistoa
  1. 3 0
      arch/x86/kernel/kprobes.c
  2. 3 1
      kernel/kprobes.c

+ 3 - 0
arch/x86/kernel/kprobes.c

@@ -337,6 +337,9 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
 
 
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
 {
+	if (alternatives_text_reserved(p->addr, p->addr))
+		return -EINVAL;
+
 	if (!can_probe((unsigned long)p->addr))
 	if (!can_probe((unsigned long)p->addr))
 		return -EILSEQ;
 		return -EILSEQ;
 	/* insn: must be on special executable page on x86. */
 	/* insn: must be on special executable page on x86. */

+ 3 - 1
kernel/kprobes.c

@@ -44,6 +44,7 @@
 #include <linux/debugfs.h>
 #include <linux/debugfs.h>
 #include <linux/kdebug.h>
 #include <linux/kdebug.h>
 #include <linux/memory.h>
 #include <linux/memory.h>
+#include <linux/ftrace.h>
 
 
 #include <asm-generic/sections.h>
 #include <asm-generic/sections.h>
 #include <asm/cacheflush.h>
 #include <asm/cacheflush.h>
@@ -703,7 +704,8 @@ int __kprobes register_kprobe(struct kprobe *p)
 
 
 	preempt_disable();
 	preempt_disable();
 	if (!kernel_text_address((unsigned long) p->addr) ||
 	if (!kernel_text_address((unsigned long) p->addr) ||
-	    in_kprobes_functions((unsigned long) p->addr)) {
+	    in_kprobes_functions((unsigned long) p->addr) ||
+	    ftrace_text_reserved(p->addr, p->addr)) {
 		preempt_enable();
 		preempt_enable();
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}