lkml.org 
[lkml]   [2004]   [Oct]   [23]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateFri, 22 Oct 2004 21:53:43 -0700
FromRoland McGrath <>
SubjectRe: ptrace problem in 2.6.9
This is indeed a new bug, and it is not architecture-specific.  In my
recent changes to close some race conditions, I overlooked the case of a
process using PTRACE_ATTACH on its own children.  The new PT_ATTACHED flag
does not really mean "PTRACE_ATTACH was used", it means "PTRACE_ATTACH is
changing the ->parent link".  This patch fixes the problem that your test
program demonstrates.


Thanks,
Roland

Signed-off-by: Roland McGrath <roland@redhat.com>

--- linux-2.6/kernel/ptrace.c 19 Oct 2004 06:12:06 -0000 1.38
+++ linux-2.6/kernel/ptrace.c 23 Oct 2004 04:43:20 -0000
@@ -132,7 +132,8 @@ int ptrace_attach(struct task_struct *ta
 		goto bad;
 
 	/* Go */
-	task->ptrace |= PT_PTRACED | PT_ATTACHED;
+	task->ptrace |= PT_PTRACED | ((task->real_parent != current)
+				      ? PT_ATTACHED : 0);
 	if (capable(CAP_SYS_PTRACE))
 		task->ptrace |= PT_PTRACE_CAP;
 	task_unlock(task);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:07    [from the cache]
©2003-2008