mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andrea Arcangeli <andrea@suse.de>,
	Andreas Schwab <schwab@suse.de>, Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: zombie with CLONE_THREAD
Date: Thu, 1 Jul 2004 00:06:51 -0700	[thread overview]
Message-ID: <200407010706.i6176pTa019793@magilla.sf.frob.com> (raw)
In-Reply-To: Linus Torvalds's message of  Wednesday, 30 June 2004 22:56:18 -0700 <Pine.LNX.4.58.0406302250120.11212@ppc970.osdl.org>

> On Wed, 30 Jun 2004, Roland McGrath wrote:
> > 
> > No, I am preserving the feature that the child doesn't go away in this case.
> > ptraced threads always become zombies and let the ptracer see their exit
> > notification and status value.  That is the way we want it to stay.
> 
> Umm.. This is not the "ptrace_list". This is the _regular_ child list.

The ptrace_list/ptrace_children list is the list of your natural children
that someone else has stolen by tracing them.  The "regular" child list is
all your natural children that noone has stolen, plus the ones you are
tracing.  We are talking here about an element on your "regular" child list
that is one you have stolen by tracing it, not a natural child.  If it is a
natural child, whether or not you are tracing it, this is not the case we
have been addressing so far.

> Which means that a bad person can try to:
>  - have "normal" children that are self-reaping.
>  - _also_ have a self-reaping ptraced child.
> 
> Now those _normal_ children may go away, no?

I think you are talking about this case:

	#include <signal.h>
	#include <unistd.h>
	#include <sys/ptrace.h>

	int main (void)
	{
	  signal(SIGCHLD,SIG_IGN);
	  switch (fork()) {
	  case -1:perror("fork");return 2;
	  case 0: ptrace(PTRACE_TRACEME, 0, (char *) 1, 0); _exit(2);
	  default:
	    sleep(2);
	    return 0;
	  }
	}

This program leaves a leaked zombie around.  That is fixed by handling the
case in reparent_thread where it possibly calls do_notify_parent in the
same way as the forget_original_parent case.  Not surprising, as both
places have the same existing code to handle the same issue--and both
overlook the same case.  I've just tested a version of my prior patch that
covers this case as well, and it works.  I can give you either the
lock-reacquiring version of that or the version based on the
list-collection patch I just posted.

> .. since this information should be available anyway (we'll have woken up 
> the tracer, and the tracer will see that the child is gone by simply 
> seeing the ESRCH errorcode from ptrace).

When did you wake up the tracer?  I don't see how that happened.  If the
tracer is blocked in a wait4 call and still has other live children, it
stays blocked.  Next time it wakes up for some other reason, it can poll
via a wait4 or ptrace call for each specific thread it knows it was
attached to and ascertain through ESRCH errors when one died.  
Having to do that sucks ass.


Thanks,
Roland

  reply	other threads:[~2004-07-01  7:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-30  6:00 Andrea Arcangeli
2004-06-30  6:08 ` Andrew Morton
2004-06-30  7:14   ` Roland McGrath
2004-06-30  9:04     ` Andreas Schwab
2004-07-01  3:22       ` Roland McGrath
2004-07-01  4:08         ` Andrea Arcangeli
2004-07-01  4:42           ` Linus Torvalds
2004-07-01  5:39           ` Roland McGrath
2004-07-01  5:56             ` Linus Torvalds
2004-07-01  7:06               ` Roland McGrath [this message]
2004-07-01 14:26                 ` Andrea Arcangeli
2004-07-01 21:33                   ` Roland McGrath
2004-07-01 15:49                 ` Linus Torvalds
2004-07-01 16:23                   ` Andrea Arcangeli
2004-07-01 16:43                     ` Linus Torvalds
2004-07-01 20:27                   ` Roland McGrath
2004-07-01  4:57         ` Linus Torvalds
2004-07-01  7:02           ` Roland McGrath
2004-07-01 16:50             ` 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=200407010706.i6176pTa019793@magilla.sf.frob.com \
    --to=roland@redhat.com \
    --cc=akpm@osdl.org \
    --cc=andrea@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwab@suse.de \
    --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®