public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
To: "Mao, Bibo" <bibo.mao@intel.com>
Cc: "Keshavamurthy, Anil S" <anil.s.keshavamurthy@intel.com>,
	        systemtap@sources.redhat.com
Subject: Re: Kprobes might be stealing int3
Date: Fri, 24 Feb 2006 02:39:00 -0000	[thread overview]
Message-ID: <20060224023923.GA3461@in.ibm.com> (raw)
In-Reply-To: <9FBCE015AF479F46B3B410499F3AE05B0898FC@pdsmsx405>

On Fri, Feb 24, 2006 at 08:56:47AM +0800, Mao, Bibo wrote:
> Anil,
> I search the x86 assembly manual, about INT instruction there are three kinds:
> 	CC 		INT 3 		Interrupt 3―trap to debugger
> 	CD ib 	INT imm8 		Interrupt vector number specified by immediate byte
> 	CE 		INTO 		Interrupt 4―if overflow flag is 1
> So like this test program, the instruction encoding will be 0x03cd, it has the same effect with 0xcc encoding. 
> And currently in kprobe BREAK_INSTRUCTION is only defined as 0xcc. Maybe another encoding also need be judged.

I think you are right. We had a similar problem with PowerPC where you
can potentially have _many_ opcodes for a "TRAP". For a while, GDB on
Power was borken 'cos we weren't taking care of all cases. That resulted
in the IS_TRAP() macro in include/asm-powerpc/kprobes.h. Something of
that sort may be needed for the other archs in question.

In effect, the 
	if (*addr != BREAKPOINT_INSTRUCTION)
must be expanded to consider the other opcode cases and pass on control
to other apps that may be waiting on it (Again check 
arch/powerpc/kernel/kprobes.c for usage of IS_TRAP).

Ananth

> Thanks
> bibo,mao
> 
> >-----Original Message-----
> >From: systemtap-owner@sourceware.org [mailto:systemtap-owner@sourceware.org]
> >On Behalf Of Keshavamurthy, Anil S
> >Sent: 2006年2月24日 7:34
> >To: systemtap@sources.redhat.com
> >Subject: FW: Kprobes might be stealing int3
> >
> >I went little further and found why the application is segmentation
> >fault'ing.
> >
> >In the kprobes_handler() code, we are checking
> >If (*addr != BREAK_INSTRUCTION)  and this is where the
> >app is crashing since we are trying to dereference this address
> >which is not a linear address.
> >
> >I would be happy to tryout any fix that any one provides.
> >
> >Thanks,
> >Anil
> >-----Original Message-----
> >From: Keshavamurthy Anil S [mailto:anil.s.keshavamurthy@intel.com]
> >Sent: Thursday, February 23, 2006 12:11 PM
> >To: Systemtap
> >Cc: Keshavamurthy, Anil S
> >Subject: Kprobes might be stealing int3
> >
> >Hi,
> >	I tried running the below program on both
> >x86_64 and i386 and on both architecture,
> >if the kernel is compiled with CONFIG_KPROBES,
> >my below application segmentation faults.
> >
> >On kernel where CONFIG_KPROBES set to N, the
> >same test program passes.
> >
> >Here goes the test program...
> >-------------------------
> >#include <stdlib.h>
> >#include <signal.h>
> >
> >void my_trap(int sig)
> >{
> > printf("Test passed, all OK\n");
> > exit(0);
> >}
> >
> >int main()
> >{
> > signal(SIGTRAP, my_trap);
> > asm volatile (".byte 0xcd,3");
> > printf("Stolen interrupt, very bad!\n");
> >}
> >----------------------------------
> >
> >
> >
> >
> >
> >

  reply	other threads:[~2006-02-24  2:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-24  0:56 Mao, Bibo
2006-02-24  2:39 ` Ananth N Mavinakayanahalli [this message]
2006-02-24  5:17 ` Prasanna S Panchamukhi
  -- strict thread matches above, loose matches on Subject: below --
2006-02-24  6:39 Mao, Bibo
2006-02-24  6:53 ` Prasanna S Panchamukhi
2006-02-23 20:10 Keshavamurthy Anil S

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=20060224023923.GA3461@in.ibm.com \
    --to=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=bibo.mao@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).