public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luca Falavigna <dktrkranz@gmail.com>
To: prasanna@in.ibm.com
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] Kprobes: Verify probepoint in register_jprobe()
Date: Wed, 29 Jun 2005 15:24:22 +0000	[thread overview]
Message-ID: <42C2BD26.7090209@gmail.com> (raw)

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





             reply	other threads:[~2005-06-29 16:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-29 15:24 Luca Falavigna [this message]
2005-06-29 18:31 ` [PATCH] Kprobes: Verify probepoint in register_jprobe() Andrew Morton
2005-06-30 14:13 ` Paulo Marques

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42C2BD26.7090209@gmail.com \
    --to=dktrkranz@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prasanna@in.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox