From: Satoshi Oshima <soshima@redhat.com>
To: Andi Kleen <ak@suse.de>, Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, systemtap@sources.redhat.com,
"Keshavamurthy, Anil S" <anil.s.keshavamurthy@intel.com>,
Ananth N Mavinakayanahalli <mananth@in.ibm.com>,
Jim Keniston <jkenisto@us.ibm.com>,
Prasanna S Panchamukhi <prasanna@in.ibm.com>,
"Hideo AOKI@redhat" <haoki@redhat.com>,
Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp>,
sugita <sugita@sdl.hitachi.co.jp>
Subject: [PATCH] kprobes: bad manupilation of 2 byte opcode on x86_64
Date: Thu, 18 May 2006 17:32:18 -0400 [thread overview]
Message-ID: <446CE7E2.8050302@redhat.com> (raw)
Hi Andi and Andrew,
I found a bug of kprobes on x86_64.
I attached the fix of this bug.
Problem:
If we put a probe onto a callq instruction and the probe
is executed, kernel panic of Bad RIP value occurs.
Root cause:
If resume_execution() found 0xff at first byte of
p->ainsn.insn, it must check the _second_ byte.
But current resume_execution check _first_ byte again.
I changed it checks second byte of p->ainsn.insn.
Kprobes on i386 don't have this problem, because
the implementation is a little bit different from
x86_64.
Regards,
Satoshi Oshima
Hitachi Computer Product (America) Inc.
----------------------------------------------
diff -Narup linux-2.6.17-rc3-mm1.orig/arch/x86_64/kernel/kprobes.c x86_64_bugifx/arch/x86_64/kernel/kprobes.c
--- linux-2.6.17-rc3-mm1.orig/arch/x86_64/kernel/kprobes.c 2006-05-04 12:34:44.000000000 -0400
+++ x86_64_bugifx/arch/x86_64/kernel/kprobes.c 2006-05-12 16:02:35.000000000 -0400
@@ -514,13 +514,13 @@ static void __kprobes resume_execution(s
*tos = orig_rip + (*tos - copy_rip);
break;
case 0xff:
- if ((*insn & 0x30) == 0x10) {
+ if ((insn[1] & 0x30) == 0x10) {
/* call absolute, indirect */
/* Fix return addr; rip is correct. */
next_rip = regs->rip;
*tos = orig_rip + (*tos - copy_rip);
- } else if (((*insn & 0x31) == 0x20) || /* jmp near, absolute indirect */
- ((*insn & 0x31) == 0x21)) { /* jmp far, absolute indirect */
+ } else if (((insn[1] & 0x31) == 0x20) || /* jmp near, absolute indirect */
+ ((insn[1] & 0x31) == 0x21)) { /* jmp far, absolute indirect */
/* rip is correct. */
next_rip = regs->rip;
}
next reply other threads:[~2006-05-18 21:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-18 21:32 Satoshi Oshima [this message]
2006-05-19 8:29 ` [PATCH] kprobes: bad manipulation of 2 byte opcode on x86_64 Richard J Moore
2006-05-19 11:33 ` Andi Kleen
2006-05-19 14:13 ` Satoshi Oshima
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=446CE7E2.8050302@redhat.com \
--to=soshima@redhat.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=anil.s.keshavamurthy@intel.com \
--cc=haoki@redhat.com \
--cc=hiramatu@sdl.hitachi.co.jp \
--cc=jkenisto@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mananth@in.ibm.com \
--cc=prasanna@in.ibm.com \
--cc=sugita@sdl.hitachi.co.jp \
--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