From: Daniel Jacobowitz <dan@debian.org>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix for ptrace breakage
Date: Mon, 16 Sep 2002 12:05:37 -0400 [thread overview]
Message-ID: <20020916160537.GA12905@nevyn.them.org> (raw)
In-Reply-To: <87fzwasz96.fsf@devron.myhome.or.jp>
On Tue, Sep 17, 2002 at 12:57:57AM +0900, OGAWA Hirofumi wrote:
> Daniel Jacobowitz <dan@debian.org> writes:
>
> > > > Some comments. First of all, you said you fixed a race on
> > > > current->ptrace and some other bugs - would you mind saying where they
> > > > were? It's definitely cleaner after your patch but I'd like to
> > > > understand where you found bugs, since I think you're introducing more.
> > >
> > > It's the following
> > >
> > > task_t *trace_task = p->parent;
> > > int ptrace_flag = p->ptrace;
> > > BUG_ON (ptrace_flag == 0);
> > >
> > > __ptrace_unlink(p);
> > > p->ptrace = ptrace_flag;
> > > __ptrace_link(p, trace_task);
> >
> > We have the tasklist lock. How can there be a race here? The parent
> > can't detach while we're holding the tasklist lock. If there is a race
> > with PTRACE_SETOPTIONS, then PTRACE_SETOPTIONS should take the lock.
>
> No. If the real parent don't change ->ptrace, it doesn't need
> lock.
I don't understand what you mean by that. Do you mean, "if it does
change ->ptrace, it doesn't need a lock"?
The locking requirements for tsk->ptrace are not documented anywhere
right now; we basically don't have any.
> > > > So you reparent children on the ptrace_list right here. But they still
> > > > need to go through zap_thread! You're right, the do_notify_parent in
> > > > zap_thread isn't necessary; it'll be taken care of in sys_wait4. The
> > > > orphaned pgrp check is still relevant though.
> > >
> > > ??? You forget tasklist_lock?
> >
> > Huh?
> >
> > The problem I am describing is when a child - which will become an
> > orphaned pgrp when ``father'' dies - is being ptraced at the moment of
> > ``father''s death. With your patch it will be moved to
> > reaper->ptrace_children (or child_reaper->ptrace_children) but never
> > orphaned properly. It'll miss a signal.
> >
> > > > If you're going to remove the if, you need to maintain its effect!
> > > > See:
> > > > > - if (p->parent != father) {
> > > > > - BUG_ON(p->parent != p->real_parent);
> > > > > - return;
> > > > > - }
> > > >
> > > > This is the case where we were tracing something. The ptrace_unlink
> > > > returned it to its original parent. It doesn't need the
> > > > remove_parent/add_parent (though they are harmless); it does need to
> > > > avoid the orphaned pgrp check. It may need the do_notify_parent check,
> > > > which was a bug in the previous code.
> > >
> > > What is the basis which you think it is bug?
> >
> > The death of a tracing process should not have any effect on the traced
> > process except to untrace it. It should not go through the orphaning
> > checks. The orphaning checks assume that the exiting process is the
> > real parent, and will orphan the pgrp if it is not in the same
> > session... as its tracer! That's a bug.
>
> Ah, ok. I think, it's longtime (odd) behavior. And you think, it's
> a bug. Right?
>
> And, both of your and old code has odd behavior. yes?
Before your patch, do_notify_parent didn't get called; I think that
perhaps it should be. I'll think about that. After your patch the
process group will be unexpectedly orphaned, which is not now the case.
Let me sit on this for a couple of hours. I'll send you an alternative
patch to look at.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
next prev parent reply other threads:[~2002-09-16 16:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-16 10:56 [PATCH] Fix for ptrace breakage OGAWA Hirofumi
2002-09-16 11:23 ` Ingo Molnar
2002-09-16 11:41 ` OGAWA Hirofumi
2002-09-16 11:50 ` Ingo Molnar
2002-09-16 11:58 ` OGAWA Hirofumi
2002-09-16 12:44 ` OGAWA Hirofumi
2002-09-16 13:07 ` Daniel Jacobowitz
2002-09-16 14:28 ` OGAWA Hirofumi
2002-09-16 14:42 ` Daniel Jacobowitz
2002-09-16 15:57 ` OGAWA Hirofumi
2002-09-16 16:05 ` Daniel Jacobowitz [this message]
2002-09-16 17:44 ` OGAWA Hirofumi
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=20020916160537.GA12905@nevyn.them.org \
--to=dan@debian.org \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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