public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] kprobes: verify jprobe entry point
@ 2010-08-03  7:25 Namhyung Kim
  2010-08-03 11:27 ` Masami Hiramatsu
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Namhyung Kim @ 2010-08-03  7:25 UTC (permalink / raw)
  To: kernel-janitors

verify jprobe's entry point is a function entry point
using kallsyms' offset value.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 8f96701..c7295f9 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1334,19 +1334,25 @@ unsigned long __weak arch_deref_entry_point(void *entry)
 int __kprobes register_jprobes(struct jprobe **jps, int num)
 {
 	struct jprobe *jp;
-	int ret = 0, i;
+	int ret = -EINVAL, i;
 
 	if (num <= 0)
-		return -EINVAL;
+		return ret;
 	for (i = 0; i < num; i++) {
 		unsigned long addr;
+		unsigned long size, offset;
+		char namebuf[KSYM_NAME_LEN];
+
 		jp = jps[i];
 		addr = arch_deref_entry_point(jp->entry);
 
-		/* Todo: Verify probepoint is a function entry point */
-		jp->kp.pre_handler = setjmp_pre_handler;
-		jp->kp.break_handler = longjmp_break_handler;
-		ret = register_kprobe(&jp->kp);
+		/* Verify probepoint is a function entry point */
+		if (kallsyms_lookup(addr, &size, &offset, NULL, namebuf) &&
+		    offset = 0) {
+			jp->kp.pre_handler = setjmp_pre_handler;
+			jp->kp.break_handler = longjmp_break_handler;
+			ret = register_kprobe(&jp->kp);
+		}
 
 		if (ret < 0) {
 			if (i > 0)
-- 
1.7.0.4


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

end of thread, other threads:[~2010-08-05 11:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-03  7:25 [PATCH 2/2] kprobes: verify jprobe entry point Namhyung Kim
2010-08-03 11:27 ` Masami Hiramatsu
2010-08-03 13:00 ` Namhyung Kim
2010-08-03 13:42 ` Namhyung Kim
2010-08-04  4:26 ` Masami Hiramatsu
2010-08-04 13:34 ` Namhyung Kim
2010-08-05  9:06 ` Masami Hiramatsu
2010-08-05  9:41 ` walter harms
2010-08-05  9:47 ` Julia Lawall
2010-08-05  9:59 ` Dan Carpenter
2010-08-05 11:14 ` Håkon Løvdal

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