From: Masami Hiramatsu <mhiramat@redhat.com>
To: Ingo Molnar <mingo@elte.hu>, lkml <linux-kernel@vger.kernel.org>
Cc: systemtap <systemtap@sources.redhat.com>,
DLE <dle-develop@lists.sourceforge.net>,
Masami Hiramatsu <mhiramat@redhat.com>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Dave Anderson <anderson@redhat.com>, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH -tip 2/2] [BUGFIX] kprobes/x86: Fix removed int3 checking order
Date: Tue, 27 Apr 2010 18:33:49 -0400 [thread overview]
Message-ID: <20100427223348.2322.9112.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20100427223312.2322.60512.stgit@localhost6.localdomain6>
Fix kprobe/x86 to check removed int3 when failing to get kprobe
from hlist. Since we have a time window between checking int3
exists on probed address and getting kprobe on that address,
we can have following senario.
-------
CPU1 CPU2
hit int3
check int3 exists
remove int3
remove kprobe from hlist
get kprobe from hlist
no kprobe->OOPS!
-------
This patch moves int3 checking if there is no kprobe on that
address for fixing this problem as follows;
------
CPU1 CPU2
hit int3
remove int3
remove kprobe from hlist
get kprobe from hlist
no kprobe->check int3 exists
->rollback&retry
------
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Dave Anderson <anderson@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/kprobes.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index f2f56c0..345a4b1 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -542,20 +542,6 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
struct kprobe_ctlblk *kcb;
addr = (kprobe_opcode_t *)(regs->ip - sizeof(kprobe_opcode_t));
- if (*addr != BREAKPOINT_INSTRUCTION) {
- /*
- * The breakpoint instruction was removed right
- * after we hit it. Another cpu has removed
- * either a probepoint or a debugger breakpoint
- * at this address. In either case, no further
- * handling of this interrupt is appropriate.
- * Back up over the (now missing) int3 and run
- * the original instruction.
- */
- regs->ip = (unsigned long)addr;
- return 1;
- }
-
/*
* We don't want to be preempted for the entire
* duration of kprobe processing. We conditionally
@@ -587,6 +573,19 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
setup_singlestep(p, regs, kcb, 0);
return 1;
}
+ } else if (*addr != BREAKPOINT_INSTRUCTION) {
+ /*
+ * The breakpoint instruction was removed right
+ * after we hit it. Another cpu has removed
+ * either a probepoint or a debugger breakpoint
+ * at this address. In either case, no further
+ * handling of this interrupt is appropriate.
+ * Back up over the (now missing) int3 and run
+ * the original instruction.
+ */
+ regs->ip = (unsigned long)addr;
+ preempt_enable_no_resched();
+ return 1;
} else if (kprobe_running()) {
p = __get_cpu_var(current_kprobe);
if (p->break_handler && p->break_handler(p, regs)) {
--
Masami Hiramatsu
e-mail: mhiramat@redhat.com
next prev parent reply other threads:[~2010-04-27 22:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-27 22:33 [PATCH -tip 1/2] [RESEND] kprobes: Move enable/disable_kprobe() out from debugfs code Masami Hiramatsu
2010-04-27 22:33 ` Masami Hiramatsu [this message]
2010-04-28 3:00 ` [PATCH -tip 2/2] [BUGFIX] kprobes/x86: Fix removed int3 checking order Ananth N Mavinakayanahalli
2010-04-28 15:39 ` Masami Hiramatsu
2010-04-29 4:27 ` Ananth N Mavinakayanahalli
2010-05-08 11:30 ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2010-05-11 7:25 ` tip-bot for Masami Hiramatsu
2010-05-08 15:40 ` [PATCH -tip 1/2] [RESEND] kprobes: Move enable/disable_kprobe() out from debugfs code Masami Hiramatsu
2010-05-08 16:08 ` Ingo Molnar
2010-05-08 18:20 ` [tip:perf/core] " tip-bot for 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=20100427223348.2322.9112.stgit@localhost6.localdomain6 \
--to=mhiramat@redhat.com \
--cc=ananth@in.ibm.com \
--cc=anderson@redhat.com \
--cc=dle-develop@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=systemtap@sources.redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.