Return ESRCH when a kernel stack is queried on a process in execve() --

p_candebug() will return EAGAIN which, if the other process never
leaves execve(), will result in the sysctl spinning and never returning
to userspace.  Processes should always eventually leave execve(), but
spinning in kernel while we wait is bad for countless reasons, and
particularly harmful if execve() itself is deadlocked.

Possibly we should return another error, or return a marker indicating
the thread is in execve() so it can be reported that way in userspace.

Reported by:	kris
This commit is contained in:
Robert Watson 2007-12-27 22:44:01 +00:00
parent 09f97b49dd
commit 0417fe5421

View File

@ -1461,7 +1461,8 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS)
name = (int *)arg1;
if ((p = pfind((pid_t)name[0])) == NULL)
return (ESRCH);
if (p->p_flag & P_WEXIT) {
/* XXXRW: Not clear ESRCH is the right error during proc execve(). */
if (p->p_flag & P_WEXIT || p->p_flag & P_INEXEC) {
PROC_UNLOCK(p);
return (ESRCH);
}