public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Kprobes: Verify probepoint in register_jprobe()
@ 2005-06-29 15:24 Luca Falavigna
  2005-06-29 18:31 ` Andrew Morton
  2005-06-30 14:13 ` Paulo Marques
  0 siblings, 2 replies; 3+ messages in thread
From: Luca Falavigna @ 2005-06-29 15:24 UTC (permalink / raw)
  To: prasanna; +Cc: Linux Kernel Mailing List

This patch, built against version 2.6.12, checks if probepoint address is a
function entry point using an offset value, obtained from kallsyms_lookup().
If offset is zero, we register jprobe, otherwise we return -EINVAL.


Signed-off-by: Luca Falavigna <dktrkranz@gmail.com>

--- ./kernel/kprobes.c.orig	2005-06-29 00:17:43.000000000 +0000
+++ ./kernel/kprobes.c	2005-06-29 11:08:02.000000000 +0000
@@ -33,6 +33,7 @@
 #include <linux/hash.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/kallsyms.h>
 #include <asm/cacheflush.h>
 #include <asm/errno.h>
 #include <asm/kdebug.h>
@@ -245,7 +246,15 @@ static struct notifier_block kprobe_exce

 int register_jprobe(struct jprobe *jp)
 {
-	/* Todo: Verify probepoint is a function entry point */
+	unsigned long size, offset;
+	char *modname, namebuf[KSYM_NAME_LEN+1];
+	
+	kallsyms_lookup((unsigned long)jp->kp.addr, &size,
+			&offset, &modname, namebuf);
+	
+	if(unlikely(offset))
+		return -EINVAL;
+	
 	jp->kp.pre_handler = setjmp_pre_handler;
 	jp->kp.break_handler = longjmp_break_handler;


Regards,
-- 
					Luca





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-06-30 14:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-29 15:24 [PATCH] Kprobes: Verify probepoint in register_jprobe() Luca Falavigna
2005-06-29 18:31 ` Andrew Morton
2005-06-30 14:13 ` Paulo Marques

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox