Commit ccfe3b20 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] ptrace-fix-2.5.33-A1

This contains Daniel's suggested fix that allows a parent to
PTRACE_ATTACH to a child it forked.  That fixes the incorrect BUG_ON()
assert that Ogawa's patch was intended to fix, and we thus undo Ogawa's
patch.

I've tested various ptrace uses and they appear to work just fine.
parent 3de1e318
...@@ -66,7 +66,8 @@ static void release_task(struct task_struct * p) ...@@ -66,7 +66,8 @@ static void release_task(struct task_struct * p)
atomic_dec(&p->user->processes); atomic_dec(&p->user->processes);
security_ops->task_free_security(p); security_ops->task_free_security(p);
free_uid(p->user); 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); unhash_process(p);
release_thread(p); release_thread(p);
...@@ -718,8 +719,14 @@ asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struc ...@@ -718,8 +719,14 @@ asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struc
ptrace_unlink(p); ptrace_unlink(p);
do_notify_parent(p, SIGCHLD); do_notify_parent(p, SIGCHLD);
write_unlock_irq(&tasklist_lock); 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); release_task(p);
}
goto end_wait4; goto end_wait4;
default: default:
continue; continue;
......
...@@ -29,7 +29,7 @@ void __ptrace_link(task_t *child, task_t *new_parent) ...@@ -29,7 +29,7 @@ void __ptrace_link(task_t *child, task_t *new_parent)
if (!list_empty(&child->ptrace_list)) if (!list_empty(&child->ptrace_list))
BUG(); BUG();
if (child->parent == new_parent) if (child->parent == new_parent)
BUG(); return;
list_add(&child->ptrace_list, &child->parent->ptrace_children); list_add(&child->ptrace_list, &child->parent->ptrace_children);
REMOVE_LINKS(child); REMOVE_LINKS(child);
child->parent = new_parent; child->parent = new_parent;
......
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