From: Jim Keniston <jkenisto@us.ibm.com>
To: LKML <linux-kernel@vger.kernel.org>, Andrew Morton <akpm@osdl.org>
Cc: Prasanna Panchamukhi <ppancham@in.ibm.com>,
SystemTAP <systemtap@sources.redhat.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH] Fix kprobes handling of simultaneous probe hit/unregister
Date: 31 Aug 2005 14:53:37 -0700 [thread overview]
Message-ID: <1125525217.2855.35.camel@localhost.localdomain> (raw)
[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]
This patch fixes a bug in kprobes's handling of a corner case on i386
and x86_64. On an SMP system, if one CPU unregisters a kprobe just
after another CPU hits that probepoint, kprobe_handler() on the latter
CPU sees that the kprobe has been unregistered, and attempts to let the
CPU continue as if the probepoint hadn't been hit. The bug is that on
i386 and x86_64, we were neglecting to set the IP back to the beginning
of the probed instruction. This could cause an oops or crash.
This bug doesn't exist on ppc64 and ia64, where a breakpoint
instruction leaves the IP pointing to the beginning of the instruction.
I don't know about sparc64. (Dave, could you please advise?)
This fix has been tested on i386 and x86_64 SMP systems. To reproduce
the problem, set one CPU to work registering and unregistering a kprobe
repeatedly, and another CPU pounding the probepoint in a tight loop.
Please apply.
Acked-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
[-- Attachment #2: kprobes_unregister_fix.patch --]
[-- Type: text/plain, Size: 1065 bytes --]
--- linux-2.6.13/arch/i386/kernel/kprobes.c 2005-08-30 12:27:35.000000000 -0700
+++ linux-fixed/arch/i386/kernel/kprobes.c 2005-08-30 15:33:03.000000000 -0700
@@ -220,7 +220,10 @@
* 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->eip -= sizeof(kprobe_opcode_t);
ret = 1;
}
/* Not one of ours: let kernel handle it */
--- linux-2.6.13/arch/x86_64/kernel/kprobes.c 2005-08-30 12:27:35.000000000 -0700
+++ linux-fixed/arch/x86_64/kernel/kprobes.c 2005-08-30 15:32:31.000000000 -0700
@@ -360,7 +360,10 @@
* 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->rip = (unsigned long)addr;
ret = 1;
}
/* Not one of ours: let kernel handle it */
next reply other threads:[~2005-08-31 21:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-31 21:53 Jim Keniston [this message]
2005-08-31 22:27 ` David S. Miller
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=1125525217.2855.35.camel@localhost.localdomain \
--to=jkenisto@us.ibm.com \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=ppancham@in.ibm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®