lkml.org 
[lkml]   [2005]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Kprobes: Verify probepoint in register_jprobe()
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




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-06-29 18:53    [W:0.043 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site