diff options
-rw-r--r-- | kernel/ptrace.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 9a34bd80a745..c8e0e050a36a 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -456,8 +456,6 @@ static bool __ptrace_detach(struct task_struct *tracer, struct task_struct *p) | |||
456 | 456 | ||
457 | static int ptrace_detach(struct task_struct *child, unsigned int data) | 457 | static int ptrace_detach(struct task_struct *child, unsigned int data) |
458 | { | 458 | { |
459 | bool dead = false; | ||
460 | |||
461 | if (!valid_signal(data)) | 459 | if (!valid_signal(data)) |
462 | return -EIO; | 460 | return -EIO; |
463 | 461 | ||
@@ -467,18 +465,19 @@ static int ptrace_detach(struct task_struct *child, unsigned int data) | |||
467 | 465 | ||
468 | write_lock_irq(&tasklist_lock); | 466 | write_lock_irq(&tasklist_lock); |
469 | /* | 467 | /* |
470 | * This child can be already killed. Make sure de_thread() or | 468 | * We rely on ptrace_freeze_traced(). It can't be killed and |
471 | * our sub-thread doing do_wait() didn't do release_task() yet. | 469 | * untraced by another thread, it can't be a zombie. |
472 | */ | 470 | */ |
473 | if (child->ptrace) { | 471 | WARN_ON(!child->ptrace || child->exit_state); |
474 | child->exit_code = data; | 472 | /* |
475 | dead = __ptrace_detach(current, child); | 473 | * tasklist_lock avoids the race with wait_task_stopped(), see |
476 | } | 474 | * the comment in ptrace_resume(). |
475 | */ | ||
476 | child->exit_code = data; | ||
477 | __ptrace_detach(current, child); | ||
477 | write_unlock_irq(&tasklist_lock); | 478 | write_unlock_irq(&tasklist_lock); |
478 | 479 | ||
479 | proc_ptrace_connector(child, PTRACE_DETACH); | 480 | proc_ptrace_connector(child, PTRACE_DETACH); |
480 | if (unlikely(dead)) | ||
481 | release_task(child); | ||
482 | 481 | ||
483 | return 0; | 482 | return 0; |
484 | } | 483 | } |