public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: tip-bot for Masami Hiramatsu <mhiramat@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	        jkenisto@us.ibm.com, ananth@in.ibm.com,
	        dle-develop@lists.sourceforge.net, fweisbec@gmail.com,
	        rostedt@goodmis.org, compudj@krystal.dyndns.org,
	jbaron@redhat.com,         tglx@linutronix.de,
	mhiramat@redhat.com, mingo@elte.hu,
	        systemtap@sources.redhat.com
Subject: [tip:perf/core] kprobes: Check probe address is reserved
Date: Thu, 04 Feb 2010 09:57:00 -0000	[thread overview]
Message-ID: <tip-4554dbcb85a4ed2abaa2b6fa15649b796699ec89@git.kernel.org> (raw)
In-Reply-To: <20100202214918.4694.94179.stgit@dhcp-100-2-132.bos.redhat.com>

Commit-ID:  4554dbcb85a4ed2abaa2b6fa15649b796699ec89
Gitweb:     http://git.kernel.org/tip/4554dbcb85a4ed2abaa2b6fa15649b796699ec89
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Tue, 2 Feb 2010 16:49:18 -0500
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 4 Feb 2010 09:36:19 +0100

kprobes: Check probe address is reserved

Check whether the address of new probe is already reserved by
ftrace or alternatives (on x86) when registering new probe.
If reserved, it returns an error and not register the probe.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: przemyslaw@pawelczyk.it
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Mathieu Desnoyers <compudj@krystal.dyndns.org>
Cc: Jason Baron <jbaron@redhat.com>
LKML-Reference: <20100202214918.4694.94179.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/kprobes.c |    3 +++
 kernel/kprobes.c          |    4 +++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 9453815..5de9f4a 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -337,6 +337,9 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
 
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
+	if (alternatives_text_reserved(p->addr, p->addr))
+		return -EINVAL;
+
 	if (!can_probe((unsigned long)p->addr))
 		return -EILSEQ;
 	/* insn: must be on special executable page on x86. */
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 9907a03..c3340e8 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -44,6 +44,7 @@
 #include <linux/debugfs.h>
 #include <linux/kdebug.h>
 #include <linux/memory.h>
+#include <linux/ftrace.h>
 
 #include <asm-generic/sections.h>
 #include <asm/cacheflush.h>
@@ -703,7 +704,8 @@ int __kprobes register_kprobe(struct kprobe *p)
 
 	preempt_disable();
 	if (!kernel_text_address((unsigned long) p->addr) ||
-	    in_kprobes_functions((unsigned long) p->addr)) {
+	    in_kprobes_functions((unsigned long) p->addr) ||
+	    ftrace_text_reserved(p->addr, p->addr)) {
 		preempt_enable();
 		return -EINVAL;
 	}

  reply	other threads:[~2010-02-04  9:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-02 21:41 [PATCH -tip 0/4] kprobes updates Masami Hiramatsu
2010-02-02 21:41 ` [PATCH -tip 3/4] kprobes: Check probe address is reserved Masami Hiramatsu
2010-02-04  9:57   ` tip-bot for Masami Hiramatsu [this message]
2010-02-02 21:41 ` [PATCH -tip 4/4] ftrace: Remove record freezing Masami Hiramatsu
2010-02-04  9:57   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-02-04 13:49   ` [PATCH -tip 4/4] " Steven Rostedt
2010-02-02 21:41 ` [PATCH -tip 2/4] ftrace/alternatives: Introducing *_text_reserved functions Masami Hiramatsu
2010-02-04  9:58   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-02-02 21:41 ` [PATCH -tip 1/4] [RESEND] kprobes: Disable booster when CONFIG_PREEMPT=y Masami Hiramatsu
2010-02-04  9:57   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2010-02-04  9:06 ` [PATCH -tip 0/4] kprobes updates Ingo Molnar
2010-02-04 20:37   ` Masami Hiramatsu

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=tip-4554dbcb85a4ed2abaa2b6fa15649b796699ec89@git.kernel.org \
    --to=mhiramat@redhat.com \
    --cc=ananth@in.ibm.com \
    --cc=compudj@krystal.dyndns.org \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jbaron@redhat.com \
    --cc=jkenisto@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=systemtap@sources.redhat.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).