mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ptrace children revamp
Date: Fri,  4 Apr 2008 14:00:33 -0700 (PDT)	[thread overview]
Message-ID: <20080404210033.F26CC26F8DC@magilla.localdomain> (raw)
In-Reply-To: Oleg Nesterov's message of  Saturday, 29 March 2008 16:10:19 +0300 <20080329131019.GA472@tv-sign.ru>

> >  	/*
> >  	 * pointers to (original) parent process, youngest child, younger sibling,
> >  	 * older sibling, respectively.  (p->father can be replaced with
> > -	 * p->parent->pid)
> > +	 * p->real_parent->pid)
> 
> There is no ->father in task_struct, the comment is obsolete

I took it to be referring to what replaced the field that no longer exists.
Anyway, I just tweaked the bad reference to the ptrace-specific parent field.

> FYI, arch/mips/kernel/irixsig.c uses add_parent/remove_parent. I don't know
> why irixsig.c reimplements do_wait() and friends...

That badly needs to be cleaned up.  As per recent comments from Linus in
another thread, I think we are best off letting this old cruft get broken
and having its arch people fix it to be sane.

> Unless I missed something again, this is not 100% right.
> 
> Suppose that we are ->real_parent, the child was traced by us, we ignore
> SIGCHLD, and we are doing the threaded reparenting. In that case we should
> release the child if it is dead, like the current code does.

I tried to construct a test case to demonstrate this behavior on the
existing kernel.  I couldn't manage to get it to do this.  Are you this
is "like the current code does"?  I'll send you my test case attempts
off-list and we can try together to get the right test to show this.  If
it turns out that it does not really behave this way now and so my code
is not introducing any regression, then (as usual) I'd rather fix this
separately after the cleanup.

> Even if we don't ignore SIGCHLD, we should notify our thread-group, but
> reparent_thread() skips do_notify_parent() when the new parent is from
> is from the same thread-group.

Why do you think this is wrong?  The notification is always group-wide
(a SIGCHLD to the group, and wakeup of the group-shared wait_chldexit).
So there already was a notification, and a second one seems wrong to me.

> Note also that reparent_thread() has a very old bug. When it sees the
> EXIT_ZOMBIE task, it notifies the new parent, but doesn't check if the task
> becomes detached because the new parent ignores SIGCHLD. Currently this means
> that init must have a handler for SIGCHLD or we leak zombies.

I had noticed that.  After the cleanup, we can look into fixing that.
As usual, I am first going for a set of cleanup patches that changes
exactly nothing semantically.

> Also, I think ptrace_exit() is not right,
> 
> 	if (p->exit_signal != -1 && !thread_group_empty(p))
> 		do_notify_parent(p, p->exit_signal);

Yes, that was a typo.  

> Looks wrong... Above this "p->parent != parent" check we have

This was an inadvertent change from some sloppy last-minute rebasing.
Sorry about that.  Both of these two errors were not there in the
version of the code I read over a lot of times, and I flubbed them in
when rejiggering the patches after some of the earlier feedback.  
In the correct code, the ptrace-stolen check is the very first thing
after calling eligible_child and checking its return value.

When we have resolved the issue about the test case above, I will post
a new series that fixes these flubs.


Thanks,
Roland

  parent reply	other threads:[~2008-04-04 21:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-29  3:34 [PATCH 1/2] do_wait reorganization Roland McGrath
2008-03-29  3:35 ` [PATCH 2/2] ptrace children revamp Roland McGrath
2008-03-29 10:39   ` Oleg Nesterov
2008-03-29 13:10     ` Oleg Nesterov
2008-03-29 14:37       ` Oleg Nesterov
2008-04-04 21:00       ` Roland McGrath [this message]
2008-04-05 14:06         ` Oleg Nesterov
2008-04-09 20:15           ` Roland McGrath
2008-04-13 14:24             ` Oleg Nesterov
2008-04-15  1:41               ` Roland McGrath
2008-03-29 10:35 ` [PATCH 1/2] do_wait reorganization Oleg Nesterov
2008-03-31  3:54   ` Roland McGrath
2008-03-29 16:16 ` Linus Torvalds
2008-03-31  3:27   ` Roland McGrath
2008-03-31  3:57   ` [PATCH 1/3] " Roland McGrath
2008-03-31  3:59     ` [PATCH 2/3] ptrace children revamp Roland McGrath
2008-03-31  9:12       ` Oleg Nesterov
2008-03-31  3:59     ` [PATCH 3/3] do_wait: return security_task_wait() error code in place of -ECHILD Roland McGrath
2008-03-31 11:03       ` Oleg Nesterov
2008-03-31 20:20         ` Roland McGrath
2008-03-31  8:51     ` [PATCH 1/3] do_wait reorganization Oleg Nesterov
2008-03-31 20:29       ` Roland McGrath
2008-03-31 20:07         ` 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=20080404210033.F26CC26F8DC@magilla.localdomain \
    --to=roland@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --cc=torvalds@linux-foundation.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®