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: Wed,  9 Apr 2008 13:15:55 -0700 (PDT)	[thread overview]
Message-ID: <20080409201555.7D23626F98D@magilla.localdomain> (raw)
In-Reply-To: Oleg Nesterov's message of  Saturday, 5 April 2008 18:06:56 +0400 <20080405140656.GA109@tv-sign.ru>

> Heh. You are right, the current kernel has the same (minor) bug.
> I beleive it was introduced by b2b2cbc4b2a2f389442549399a993a8306420baf.

I have a regression test program for that (the one I sent you).
I've done a fix as a follow-on patch.

> However, now I think your patch adds a more serious problem, we can really
> leak a zombie. Suppose that that we are ->real_parent, the child was traced
> by us, it is zombie now, and the child is not a group leader. No matter who
> is the new parent, no matter what is the state of SIGCHLD, we must not reparent
> the child: nobody can release it except us. It is not traced any longer,
> its ->exit_signal == -1, eligible_child() doesn't like this.
> 
> No?

(Yes!)  Ah, thanks for that.  I wrote a regression test program for this
case that worked before and fails with my last version of the patch.
I've fixed my new code so it passes again.

> Well, I was thinking about another thread (the new parent) sleeping in
> do_wait(__WNOTHREAD)... not sure this really matters, though.

I'm pretty sure it doesn't matter in real life.  I doubt whoever uses
__WNOTHREAD was relying on seeing some other thread's reparented
children.  TBH, I don't care much about __WNOTHREAD and I don't know off
hand of anything that actually uses it.  OTOH, an extra wakeup on
wait_chldexit is always harmless.  And for pure anality, it seems proper
to maintain the invariant that do_wait() wakes up promptly whenever
interrupting and restarting it would complete without blocking.  But, we
don't get that wakeup now and noone has complained, so all in all, I'm
inclined to leave it as it is.

I've put the latest tweaked version of this same patch series at:
	http://people.redhat.com/roland/kernel-patches/ptrace-cleanup.mbox
That adds a fourth patch that fixes the aforementioned bug case that the
current canonical kernel gets wrong.  I think that fix also incidentally
covered the init-ignores-SIGCHLD case, but I didn't test that and I'm
not really positive.

I'm working on a variant of the ptrace revamp where all ptrace'd tasks
go on a list (whether natural children or not).  (This was my original
intent, but then I thought it might be more complication and change that
way.  Now it's seeming attractive again.)  I tend towards this approach
aesthetically because it makes ptrace bookkeeping more consistent across
all kinds of tracees.  For the cases we've been talking about, it means
ptrace_exit() would take care of zombies kept alive by ptrace uniformly
before we get to the reparent_thread loop.  This means the init case is
separate and needs a separate fix, but that kind of seems cleaner.  When
I get the variant patch working, we can see which one looks best.  I'd
like your opinion on that.


Thanks,
Roland

  reply	other threads:[~2008-04-09 20:16 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
2008-04-05 14:06         ` Oleg Nesterov
2008-04-09 20:15           ` Roland McGrath [this message]
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=20080409201555.7D23626F98D@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®