From 0417fe5421be43b36463a294f8cd62d4fcf799d1 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Thu, 27 Dec 2007 22:44:01 +0000 Subject: [PATCH] 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 --- sys/kern/kern_proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 7fca5dddc223..c2e33a7621de 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -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); }