All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@debian.org>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Ingo Molnar <mingo@elte.hu>,
	Linus Torvalds <torvalds@transmeta.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] ptrace-fix-2.5.33-A1
Date: Fri, 6 Sep 2002 11:45:08 -0400	[thread overview]
Message-ID: <20020906154508.GA20709@nevyn.them.org> (raw)
In-Reply-To: <87vg5j2l5g.fsf@devron.myhome.or.jp>

Thanks for the comments.

On Sat, Sep 07, 2002 at 12:27:39AM +0900, OGAWA Hirofumi wrote:
> Ingo Molnar <mingo@elte.hu> writes:
> 
> > i've attached a combined patch of your two patches, against BK-curr. Looks
> > good to me, and since it passed your more complex ptrace tests ...
> > 
> > 	Ingo
> > 
> > --- linux/kernel/exit.c.orig	Fri Sep  6 00:55:02 2002
> > +++ linux/kernel/exit.c	Fri Sep  6 00:57:58 2002
> > @@ -66,6 +66,11 @@
> >  	atomic_dec(&p->user->processes);
> >  	security_ops->task_free_security(p);
> >  	free_uid(p->user);
> > +	if (unlikely(p->ptrace)) {
> > +		write_lock_irq(&tasklist_lock);
> > +		__ptrace_unlink(p);
> > +		write_unlock_irq(&tasklist_lock);
> > +	}
> >  	BUG_ON(!list_empty(&p->ptrace_list) || !list_empty(&p->ptrace_children));
> 
> Looks like it's need the only CLONE_DETACH process. Why it's here?

Because it's also needed for non-CLONE_DETACH processes.  I added it
earlier down by the release_task, remember?  I deleted it in this patch
originally, and the change got lost somewhere; my intent is to check
for this only in release_task and nowhere else.  When I have a clear
point to resync with Linus again then I'll make sure this is right.

> 	 * Search them and reparent children.
> 	 */
> 	list_for_each(_p, &father->children) {
> 		p = list_entry(_p,struct task_struct,sibling);
> 		reparent_thread(p, reaper, child_reaper);
> 	}
> 
> Looks like that tracer deprive a process from real parent.

Oh - when the tracer exits the original parent may be corrupted, you
mean?  I guess you're right.  But I've made so many changes to this bit
of code that I'd like to wait until it settles before we fix this -
it's not a new problem.

> 	list_for_each(_p, &father->ptrace_children) {
> 		p = list_entry(_p,struct task_struct,ptrace_list);
> 		reparent_thread(p, reaper, child_reaper);
> 	}
> 
> Thread group makes the child which links both ->children and
> ->ptrace_children.

I don't understand what you mean.

> >  {
> > -	ptrace_unlink(p);
> > -	list_del_init(&p->sibling);
> > -	p->ptrace = 0;
> > +	/* If we were tracing the thread, release it; otherwise preserve the
> > +	   ptrace links.  */
> > +	if (unlikely(traced)) {
> > +		task_t *trace_task = p->parent;
> > +		__ptrace_unlink(p);
> > +		p->ptrace = 1;
> 
> Unexpected change of ptrace flag.

I should've caught that, I actually use the ptrace flags here.  But the
code that uses them is suffering some other BUG() right now.

> > +		__ptrace_link(p, trace_task);
> > +	} else {
> > +		p->ptrace = 0;
> > +		list_del_init(&p->sibling);
> > +		p->parent = p->real_parent;
> > +		list_add_tail(&p->sibling, &p->parent->children);
> 
> Looks like that tracing child still link ->ptrace_list.

Right on both counts; how's this look (on top of the last patch):

===== exit.c 1.49 vs edited =====
--- 1.49/kernel/exit.c	Fri Sep  6 11:26:02 2002
+++ edited/exit.c	Fri Sep  6 11:37:50 2002
@@ -449,15 +449,19 @@
 
 static inline void zap_thread(task_t *p, task_t *father, int traced)
 {
-	/* If we were tracing the thread, release it; otherwise preserve the
-	   ptrace links.  */
+	/* If someone else is tracing this thread, preserve the ptrace links.  */
 	if (unlikely(traced)) {
 		task_t *trace_task = p->parent;
+		int ptrace_flag = p->ptrace;
+		BUG_ON (ptrace_flag == 0);
+
 		__ptrace_unlink(p);
-		p->ptrace = 1;
+		p->ptrace = ptrace_flag;
 		__ptrace_link(p, trace_task);
 	} else {
-		p->ptrace = 0;
+		/* Otherwise, if we were tracing this thread, untrace it.  */
+		ptrace_unlink (p);
+
 		list_del_init(&p->sibling);
 		p->parent = p->real_parent;
 		list_add_tail(&p->sibling, &p->parent->children);

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

  reply	other threads:[~2002-09-06 15:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-05 22:09 [patch] ptrace-fix-2.5.33-A1 Ingo Molnar
2002-09-05 22:15 ` Daniel Jacobowitz
2002-09-05 22:25   ` Ingo Molnar
2002-09-05 22:29     ` Daniel Jacobowitz
2002-09-05 22:39       ` Ingo Molnar
2002-09-05 22:50         ` Daniel Jacobowitz
2002-09-05 22:58           ` Ingo Molnar
2002-09-06 15:27             ` OGAWA Hirofumi
2002-09-06 15:45               ` Daniel Jacobowitz [this message]
2002-09-06 15:57                 ` Ingo Molnar
2002-09-06 20:44                 ` OGAWA Hirofumi
2002-09-05 22:41       ` Ingo Molnar
2002-09-05 22:52     ` Daniel Jacobowitz
2002-09-05 22:35   ` Ingo Molnar
2002-09-05 23:02     ` Daniel Jacobowitz
2002-09-05 23:08       ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2002-09-05 22:10 Ingo Molnar
2002-09-05 15:35 Ingo Molnar
2002-09-05 17:08 ` OGAWA Hirofumi
2002-09-05 18:36   ` Daniel Jacobowitz
2002-09-05 20:06     ` Ingo Molnar
2002-09-05 21:44   ` Daniel Jacobowitz
2002-09-05 22:12     ` Daniel Jacobowitz

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=20020906154508.GA20709@nevyn.them.org \
    --to=dan@debian.org \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@transmeta.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.