kprobes: Verify jprobe entry point
authorNamhyung Kim <namhyung@gmail.com>
Wed, 15 Sep 2010 01:04:27 +0000 (10:04 +0900)
committerIngo Molnar <mingo@elte.hu>
Wed, 15 Sep 2010 08:44:01 +0000 (10:44 +0200)
Verify jprobe's entry point is a function entry point
using kallsyms' offset value.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1284512670-2369-3-git-send-email-namhyung@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/kprobes.c

index 8f967016cef06dbe66126b3759c257d58d2eb145..1b0dbe0670770f2fece89c78335752ed7619b397 100644 (file)
@@ -1339,14 +1339,18 @@ int __kprobes register_jprobes(struct jprobe **jps, int num)
        if (num <= 0)
                return -EINVAL;
        for (i = 0; i < num; i++) {
-               unsigned long addr;
+               unsigned long addr, offset;
                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_size_offset(addr, NULL, &offset) &&
+                   offset == 0) {
+                       jp->kp.pre_handler = setjmp_pre_handler;
+                       jp->kp.break_handler = longjmp_break_handler;
+                       ret = register_kprobe(&jp->kp);
+               } else
+                       ret = -EINVAL;
 
                if (ret < 0) {
                        if (i > 0)