Commit 66edd549 authored by Roland McGrath's avatar Roland McGrath Committed by Linus Torvalds

[PATCH] Fix ptrace problem

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 fixes the problem that Stephane Eranian program demonstrates.
Signed-off-by: default avatarRoland McGrath <roland@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 63bd6144
......@@ -132,7 +132,8 @@ int ptrace_attach(struct task_struct *task)
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment