From: Prasanna S Panchamukhi <prasanna@in.ibm.com>
To: SystemTAP <systemtap@sources.redhat.com>,
akpm@osdl.org, Andi Kleen <ak@muc.de>,
davem@davemloft.net, ananth@in.ibm.com,
linux-kernel@vger.kernel.org
Subject: [PATCH] Kprobes: Incorrect handling of probes on ret/lret instruction
Date: Fri, 1 Apr 2005 14:07:10 +0530 [thread overview]
Message-ID: <20050401083710.GA1681@in.ibm.com> (raw)
Hi,
Kprobes could not handle the insertion of a probe on the ret/lret instruction
and used to oops after single stepping since kprobes was modifying eip/rip
incorrectly. Adjustment of eip/rip is not required after single stepping in
case of ret/lret instruction, because eip/rip points to the correct location
after execution of the ret/lret instruction. This patch fixes the above problem.
Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
---
---
linux-2.6.12-rc1-prasanna/arch/i386/kernel/kprobes.c | 7 +++++++
linux-2.6.12-rc1-prasanna/arch/x86_64/kernel/kprobes.c | 7 +++++++
2 files changed, 14 insertions(+)
diff -puN arch/i386/kernel/kprobes.c~kprobes-ret-address-fix arch/i386/kernel/kprobes.c
--- linux-2.6.12-rc1/arch/i386/kernel/kprobes.c~kprobes-ret-address-fix 2005-03-31 14:32:56.000000000 +0530
+++ linux-2.6.12-rc1-prasanna/arch/i386/kernel/kprobes.c 2005-03-31 14:37:24.000000000 +0530
@@ -218,6 +218,13 @@ static void resume_execution(struct kpro
*tos &= ~(TF_MASK | IF_MASK);
*tos |= kprobe_old_eflags;
break;
+ case 0xc3: /* ret/lret */
+ case 0xcb:
+ case 0xc2:
+ case 0xca:
+ regs->eflags &= ~TF_MASK;
+ /* eip is already adjusted, no more changes required*/
+ return;
case 0xe8: /* call relative - Fix return addr */
*tos = orig_eip + (*tos - copy_eip);
break;
diff -puN arch/x86_64/kernel/kprobes.c~kprobes-ret-address-fix arch/x86_64/kernel/kprobes.c
--- linux-2.6.12-rc1/arch/x86_64/kernel/kprobes.c~kprobes-ret-address-fix 2005-03-31 14:33:31.000000000 +0530
+++ linux-2.6.12-rc1-prasanna/arch/x86_64/kernel/kprobes.c 2005-03-31 14:37:08.000000000 +0530
@@ -231,6 +231,13 @@ static void resume_execution(struct kpro
*tos &= ~(TF_MASK | IF_MASK);
*tos |= kprobe_old_rflags;
break;
+ case 0xc3: /* ret/lret */
+ case 0xcb:
+ case 0xc2:
+ case 0xca:
+ regs->eflags &= ~TF_MASK;
+ /* rip is already adjusted, no more changes required*/
+ return;
case 0xe8: /* call relative - Fix return addr */
*tos = orig_rip + (*tos - copy_rip);
break;
_
Thanks
Prasanna
--
Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Ph: 91-80-25044636
<prasanna@in.ibm.com>
reply other threads:[~2005-04-01 8:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20050401083710.GA1681@in.ibm.com \
--to=prasanna@in.ibm.com \
--cc=ak@muc.de \
--cc=akpm@osdl.org \
--cc=ananth@in.ibm.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--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®