]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - kernel/ptrace.c
clk-bcm2835: Read max core clock from firmware
[mirror_ubuntu-zesty-kernel.git] / kernel / ptrace.c
index 49ba7c1ade9d074b814105fb648f33b0ce95f061..a5caecef88be34c84b79d7e18cd2c3778416dc2f 100644 (file)
@@ -181,11 +181,17 @@ static void ptrace_unfreeze_traced(struct task_struct *task)
 
        WARN_ON(!task->ptrace || task->parent != current);
 
+       /*
+        * PTRACE_LISTEN can allow ptrace_trap_notify to wake us up remotely.
+        * Recheck state under the lock to close this race.
+        */
        spin_lock_irq(&task->sighand->siglock);
-       if (__fatal_signal_pending(task))
-               wake_up_state(task, __TASK_TRACED);
-       else
-               task->state = TASK_TRACED;
+       if (task->state == __TASK_TRACED) {
+               if (__fatal_signal_pending(task))
+                       wake_up_state(task, __TASK_TRACED);
+               else
+                       task->state = TASK_TRACED;
+       }
        spin_unlock_irq(&task->sighand->siglock);
 }