From: Chuck Ebbert <76306.1226@compuserve.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [patch] i386: another possible singlestep fix
Date: Sat, 18 Feb 2006 00:29:54 -0500 [thread overview]
Message-ID: <200602180031_MC3-1-B8B2-E328@compuserve.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0602171412210.916@g5.osdl.org>
On Fri, 17 Feb 2006 at 14:14:06 -0800, Linus Torvalds wrote:
> On Fri, 17 Feb 2006, Chuck Ebbert wrote:
> >
> > When entering kernel via int80, TIF_SINGLESTEP is not set
> > when TF has been set in eflags by the user. This patch
> > does that.
> ...
> So afaik, this won't actually do anything (except make _the_ most
> timing-critical path in the kernel slower). Have you actually seen any
> effects of it?
No, because every time I try to write a test program I find new things
that keep me from testing what I started out to test. (Last time it was
syscalls turning off singlestep.)
Now I'm using PTRACE_SINGLESTEP to trace a program that is setting
TF while being traced. This works; TF starts showing as set after
the popf that sets it but then I tried to forward the SIGTRAP on
to the child so its signal handler could run when TF was set:
waitpid(child, &status, 0);
if (WIFSTOPPED(status)) {
int signo = WSTOPSIG(status);
ptrace(PTRACE_GETREGS, child, 0, ®s);
if (signo !=5 || !(regs.eflags & TF_MASK))
signo = 0
ptrace(PTRACE_SINGLESTEP, child, NULL, (void *)signo);
}
Now I can trace the signal handler, but when it returns TF is never
again seen as set in the child program when the tracer gets control.
This kernel patch fixes that (but doesn't handle errors properly):
--- 2.6.16-rc3-nb.orig/arch/i386/kernel/signal.c
+++ 2.6.16-rc3-nb/arch/i386/kernel/signal.c
@@ -145,6 +145,9 @@ restore_sigcontext(struct pt_regs *regs,
{
unsigned int tmpflags;
err |= __get_user(tmpflags, &sc->eflags);
+ /* user setting TF? */
+ if (tmpflags & X86_EFLAGS_TF)
+ current->ptrace &= ~PT_DTRACE;
regs->eflags = (regs->eflags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
regs->orig_eax = -1; /* disable syscall checks */
}
But now the program goes into an infinite loop because the same trap
keeps getting delivered over and over. It's almost like after the
child actually handles the signal it gets recycled somehow, the tracer
gets it, sends it to the child again and so on... So I modified the
test program to only start forwarding SIGTRAP after two in a row with
TF set have been delivered, but that shouldn't be necessary, should it?
--
Chuck
"Equations are the Devil's sentences." --Stephen Colbert
next reply other threads:[~2006-02-18 5:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-18 5:29 Chuck Ebbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-02-21 23:03 Chuck Ebbert
2006-02-17 21:49 Chuck Ebbert
2006-02-17 22:14 ` Linus Torvalds
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=200602180031_MC3-1-B8B2-E328@compuserve.com \
--to=76306.1226@compuserve.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/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®