From: Matthew Dillon Date: Thu, 16 Aug 2012 00:49:47 +0000 (-0700) Subject: Kernel - Fix numerous procfs/ptrace issues (2) X-Git-Tag: v3.2.0~387 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/3c319633569e3d5212b1b525fd5216a542996a9e Kernel - Fix numerous procfs/ptrace issues (2) * The last fix wasn't quite right. Fix it for real. --- diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index bda5911fb8..728b9c5e5c 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -177,15 +177,20 @@ pstall(struct proc *p, const char *wmesg, int count) 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)) {