public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [patch] ptrace-fix-2.5.33-A1
@ 2002-09-05 22:09 Ingo Molnar
  2002-09-05 22:15 ` Daniel Jacobowitz
  0 siblings, 1 reply; 23+ messages in thread
From: Ingo Molnar @ 2002-09-05 22:09 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: OGAWA Hirofumi, Linus Torvalds, linux-kernel


On Thu, 5 Sep 2002, Daniel Jacobowitz wrote:

> There's definitely still something wrong... let me just run through my
> understanding of these lists, to make sure we're on the same page.
> 
> tsk->children: tsk's children, which are either untraced or traced by
> 	tsk.  They have p->parent == p->real_parent == tsk.
> 	Chained in p->sibling.

no - the way i wrote it originally was that only untraced children should
be on the tsk->children list. Traced tasks will be on the debugger's
->children list, plus will be on the real parent's ->ptrace_children list.

> tsk->ptrace_children: tsk's children, which are traced by some other
> 	process.  They have p->real_parent == tsk and p->parent != tsk.
> 	Chained in p->ptrace_list.

yes. This means that the sum of the two lists gives the real, total set of
children.

this splitup of the lists makes it possible for the debugger to do a wait4
that will get events from the debugged task, and for the debugged task to
also be available to the real parent.

is this really what we want?

(note that the meaning of the lists is not necesserily cleanly expressed
via the code, all deviations are most likely bugs.)

	Ingo



^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [patch] ptrace-fix-2.5.33-A1
@ 2002-09-05 22:10 Ingo Molnar
  0 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2002-09-05 22:10 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: OGAWA Hirofumi, Linus Torvalds, linux-kernel


> > tsk->children: tsk's children, which are either untraced or traced by
> > 	tsk.  They have p->parent == p->real_parent == tsk.
> > 	Chained in p->sibling.
> 
> no - the way i wrote it originally was that only untraced children should
> be on the tsk->children list. Traced tasks will be on the debugger's
> ->children list, plus will be on the real parent's ->ptrace_children list.

i cant see how a ->children list that includes all children (traced and
untraced) can be useful. In fact it can be harmful: the debugger needs the
traced children to be on his own child-list, ie. there's a conflict of use
on the ->sibling list field. The ->ptrace_list entry is supposed to help
this situation - obviously use of ->ptrace_list and ->sibling has to be
mutually exclusive, no two parents can have the same task linked over
->sibling.

	Ingo



^ permalink raw reply	[flat|nested] 23+ messages in thread
* [patch] ptrace-fix-2.5.33-A1
@ 2002-09-05 15:35 Ingo Molnar
  2002-09-05 17:08 ` OGAWA Hirofumi
  0 siblings, 1 reply; 23+ messages in thread
From: Ingo Molnar @ 2002-09-05 15:35 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, Daniel Jacobowitz, OGAWA Hirofumi


Linus,

the attached patch (against BK-curr) collects two ptrace related fixes:  
first it undoes Ogawa's change (so various uses of ptrace works again),
plus it adds Daniel's suggested fix that allows a parent to PTRACE_ATTACH
to a child it forked. (this also fixes the incorrect BUG_ON() assert
Ogawa's patch was intended to fix in the first place.)

i've tested various ptrace uses and they appear to work just fine.

(Daniel, let us know if you can still see anything questionable in this
area - or if the ptrace list could be managed in a cleaner way.)

please apply,

	Ingo

--- linux/kernel/exit.c.orig	Thu Sep  5 17:25:47 2002
+++ linux/kernel/exit.c	Thu Sep  5 17:27:06 2002
@@ -66,7 +66,8 @@
 	atomic_dec(&p->user->processes);
 	security_ops->task_free_security(p);
 	free_uid(p->user);
-	BUG_ON(!list_empty(&p->ptrace_list) || !list_empty(&p->ptrace_children));
+	BUG_ON(p->ptrace || !list_empty(&p->ptrace_list) ||
+					!list_empty(&p->ptrace_children));
 	unhash_process(p);
 
 	release_thread(p);
@@ -718,8 +719,14 @@
 					ptrace_unlink(p);
 					do_notify_parent(p, SIGCHLD);
 					write_unlock_irq(&tasklist_lock);
-				} else
+				} else {
+					if (p->ptrace) {
+						write_lock_irq(&tasklist_lock);
+						ptrace_unlink(p);
+						write_unlock_irq(&tasklist_lock);
+					}
 					release_task(p);
+				}
 				goto end_wait4;
 			default:
 				continue;
--- linux/kernel/ptrace.c.orig	Thu Sep  5 17:28:40 2002
+++ linux/kernel/ptrace.c	Thu Sep  5 17:28:47 2002
@@ -29,7 +29,7 @@
 	if (!list_empty(&child->ptrace_list))
 		BUG();
 	if (child->parent == new_parent)
-		BUG();
+		return;
 	list_add(&child->ptrace_list, &child->parent->ptrace_children);
 	REMOVE_LINKS(child);
 	child->parent = new_parent;


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2002-09-06 20:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox