Commit 95c3eb76 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

ptrace: kill __ptrace_detach(), fix ->exit_state check

Move the code from __ptrace_detach() to its single caller and kill this
helper.

Also, fix the ->exit_state check, we shouldn't wake up EXIT_DEAD tasks.
Actually, I think task_is_stopped_or_traced() makes more sense, but this
needs another patch.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6588c1e3
...@@ -235,16 +235,6 @@ int ptrace_attach(struct task_struct *task) ...@@ -235,16 +235,6 @@ int ptrace_attach(struct task_struct *task)
return retval; return retval;
} }
static inline void __ptrace_detach(struct task_struct *child, unsigned int data)
{
child->exit_code = data;
/* .. re-parent .. */
__ptrace_unlink(child);
/* .. and wake it up. */
if (child->exit_state != EXIT_ZOMBIE)
wake_up_process(child);
}
int ptrace_detach(struct task_struct *child, unsigned int data) int ptrace_detach(struct task_struct *child, unsigned int data)
{ {
if (!valid_signal(data)) if (!valid_signal(data))
...@@ -254,10 +244,16 @@ int ptrace_detach(struct task_struct *child, unsigned int data) ...@@ -254,10 +244,16 @@ int ptrace_detach(struct task_struct *child, unsigned int data)
ptrace_disable(child); ptrace_disable(child);
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
write_lock_irq(&tasklist_lock);
/* protect against de_thread()->release_task() */ /* protect against de_thread()->release_task() */
if (child->ptrace) write_lock_irq(&tasklist_lock);
__ptrace_detach(child, data); if (child->ptrace) {
child->exit_code = data;
__ptrace_unlink(child);
if (!child->exit_state)
wake_up_process(child);
}
write_unlock_irq(&tasklist_lock); write_unlock_irq(&tasklist_lock);
return 0; return 0;
......
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