From: Markus Metzger <markus.t.metzger@googlemail.com>
To: Oleg Nesterov <oleg@redhat.com>, Ingo Molnar <mingo@elte.hu>
Cc: "Metzger, Markus T" <markus.t.metzger@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"mingo@elte.hu" <mingo@elte.hu>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"hpa@zytor.com" <hpa@zytor.com>,
"roland@redhat.com" <roland@redhat.com>,
"eranian@googlemail.com" <eranian@googlemail.com>,
"Villacis, Juan" <juan.villacis@intel.com>,
"ak@linux.jf.intel.com" <ak@linux.jf.intel.com>
Subject: Re: [patch 3/14] x86, ptrace, bts: stop bts tracing early in do_exit
Date: Sat, 28 Mar 2009 12:31:52 +0100 [thread overview]
Message-ID: <1238239912.6036.0.camel@raistlin> (raw)
In-Reply-To: <20090327172413.GC25762@redhat.com>
On Fri, 2009-03-27 at 18:24 +0100, Oleg Nesterov wrote:
> On 03/27, Metzger, Markus T wrote:
> >
> > >-----Original Message-----
> > >From: Oleg Nesterov [mailto:oleg@redhat.com]
> > >Sent: Friday, March 27, 2009 3:35 PM
> >
> > >> +static void ptrace_bts_exit(void)
> > >> +{
> > >> + if (unlikely(!list_empty(¤t->ptraced)))
> > >> + ptrace_bts_exit_tracer();
> > >> +
> > >> + if (unlikely(current->bts))
> > >> + ptrace_bts_exit_tracee();
> > >> +}
> > >
> > >Could you explain why do we need ptrace_bts_exit_tracee() ?
> > >
> > >If current is traced, the tracer should do ptrace_bts_release()
> > >eventually, no?
> >
> > If current is traced and exits, it may be reaped by another thread that is not
> > the tracer (that's actually your example you made in an earlier thread to
> > describe the race between a normal detach and an exiting tracee).
> >
> > The ptrace_unlink() call to detach the tracer is executed with irq's disabled.
> > I need irq's enabled (see the other discussion, to wait for the traced task).
>
> OK,
>
> > Therefore, I have the tracee disable bts tracing itself when it exits.
> >
> >
> > >And if we really need to do ptrace_bts_exit_tracee(), then
> > >"if (unlikely(current->bts))" check is racy. The tracer
> > >can do PTRACE_BTS_CONFIG right after the check.
> >
> > The ptrace system call to do this would require the tracee to be stopped.
>
> Yes, but this doesn't matter.
>
> The tracer starts ptrace(PTRACE_BTS_CONFIG) and stops the tracee.
> But when the tracer calls ptrace_bts_config() the tracee can be already
> killed, and it can exit and bypass ptrace_bts_exit_tracee().
Could something like that work?
ds_release_bts(struct bts_tracer *tracer)
{
struct task_struct *task =
tracer->ds.context->task;
do {
set_task_state(task, TASK_UNINTERRUPTIBLE);
while (!wait_task_inactive(task, TASK_UNINTERRUPTIBLE));
ds_suspend_bts(tracer);
ds_free_bts(tracer);
wake_up_process(task);
}
I guess it would not work in general, since task could already sleep
on some event and be woken up after the do loop.
I was thinking it might work for the exit race, since we don't sleep
during exit, but it might have started sleeping before the SIGKILL.
Isn't this a general problem for ptrace?
Ptrace uses a similar pattern in ptrace_check_attach().
It stops the traced task, but that task might wake up immediately after
that check. It might be scheduled in any time during a ptrace operation.
In that case, must I always assume I'm operating on a running task?
regards,
markus.
next prev parent reply other threads:[~2009-03-28 11:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-27 8:55 [patch 3/14] x86, ptrace, bts: stop bts tracing early in do_exit Markus Metzger
2009-03-27 14:34 ` Oleg Nesterov
2009-03-27 15:34 ` Metzger, Markus T
2009-03-27 17:24 ` Oleg Nesterov
2009-03-27 19:25 ` Markus Metzger
2009-03-28 11:31 ` Markus Metzger [this message]
2009-03-30 1:22 ` Oleg Nesterov
2009-03-30 6:55 ` Metzger, Markus T
2009-03-30 10:44 ` Andi Kleen
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=1238239912.6036.0.camel@raistlin \
--to=markus.t.metzger@googlemail.com \
--cc=ak@linux.jf.intel.com \
--cc=eranian@googlemail.com \
--cc=hpa@zytor.com \
--cc=juan.villacis@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markus.t.metzger@intel.com \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=tglx@linutronix.de \
/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