Kernel - Fix numerous procfs/ptrace issues (2)
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 16 Aug 2012 00:49:47 +0000 (17:49 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 21 Aug 2012 03:58:39 +0000 (20:58 -0700)
* The last fix wasn't quite right.  Fix it for real.

sys/kern/kern_proc.c

index bda5911..728b9c5 100644 (file)
@@ -177,15 +177,20 @@ pstall(struct proc *p, const char *wmesg, int count)
                tsleep_interlock(&p->p_lock, 0);
 
                /*
                tsleep_interlock(&p->p_lock, 0);
 
                /*
-                * If someone is trying to single-step the process they can
-                * prevent us from going into zombie-land.
+                * If someone is trying to single-step the process during
+                * an exec or an exit they can deadlock us because procfs
+                * sleeps with the process held.
                 */
                 */
-               if (p->p_step) {
-                       spin_lock(&p->p_spin);
-                       p->p_stops = 0;
-                       p->p_step = 0;
-                       spin_unlock(&p->p_spin);
-                       wakeup(&p->p_step);
+               if (p->p_stops) {
+                       if (p->p_flags & P_INEXEC) {
+                               wakeup(&p->p_stype);
+                       } else if (p->p_flags & P_POSTEXIT) {
+                               spin_lock(&p->p_spin);
+                               p->p_stops = 0;
+                               p->p_step = 0;
+                               spin_unlock(&p->p_spin);
+                               wakeup(&p->p_stype);
+                       }
                }
 
                if (atomic_cmpset_int(&p->p_lock, o, n)) {
                }
 
                if (atomic_cmpset_int(&p->p_lock, o, n)) {