From: Oleg Nesterov <oleg@redhat.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Roland McGrath <roland@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC] semantics of singlestepping vs. tracer exiting
Date: Mon, 3 Sep 2012 18:05:38 +0200 [thread overview]
Message-ID: <20120903160538.GA10114@redhat.com> (raw)
In-Reply-To: <20120903001436.GG23464@ZenIV.linux.org.uk>
On 09/03, Al Viro wrote:
>
> When tracer exits, everything that had been ptraced by it
> gets its ->ptrace reset to 0 and woken up to run. Fine, but...
> what should happen if the last thing that had been done to the
> child was PTRACE_SINGLESTEP?
Yes. If the tracer exits "unexpectedly", it can leave the tracee in
the inconsistent state.
IIRC, we already discussed this, but I can't recall the result.
> Is that a bug or deliberate
> behaviour?
This is not easy to fix. ptrace_disable() and user_disable_single_step()
is arch dependant, but at least on x86 it assumes that the tracee is not
running, so exit_ptrace() can't do this.
And (iirc) it can even sleep, but this is fixable. We can change
exit_ptrace() to drop/re-acquire tasklist.
And this also complicates PTRACE_DETACH_ASYNC which (imho) we need.
Currently the tracer can't detach the running tracee. And worse, it
can't detach a zombie. It should do wait() but if this process has
alive sub-threads it can do nothing.
This is another reason to move enable/disable step into ptrace_stop().
And in fact I had the patches a loong ago, but we need to cleanup
the usage of PT_SINGLESTEP/PT_BLOCKSTEP first. The tracer should
simply set/clear these PT_ flags and resume the tracee which should
check them and do user_*_single_step() in response.
But. Whatever we do, exit_ptrace() can race with SIGTRAP anyway.
> Related question: should execve(2) clear (ptrace-inflicted)
> singlestepping?
Perhaps, but
> Tracer
> exit(), however, does *not* do that right now, so the state after
> execve(2) is theoretically observable.
... why execve() is special?
Olef.
next parent reply other threads:[~2012-09-03 16:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20120903001436.GG23464@ZenIV.linux.org.uk>
2012-09-03 16:05 ` Oleg Nesterov [this message]
2012-09-03 17:02 ` [RFC] semantics of singlestepping vs. tracer exiting Oleg Nesterov
2012-09-03 17:31 ` Al Viro
2012-09-04 15:39 ` Oleg Nesterov
2012-09-04 16:08 ` Al Viro
2012-09-04 16:58 ` Oleg Nesterov
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=20120903160538.GA10114@redhat.com \
--to=oleg@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/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