From ded7d39cb9b0a751b27da2ee4d9d3022869e93d4 Mon Sep 17 00:00:00 2001 From: "Christian S.J. Peron" Date: Tue, 12 Aug 2008 21:27:48 +0000 Subject: [PATCH] Reduce the scope of the vnode lock such that it does not cover the various copyouts associated with initializing the process's argv/env data in userspace. It is possible that these copyout operations can fault under memory pressure, possibly resulting in dead locks. This is believed to be safe since none of the copyout_strings() operations need to interact with the vnode here. Submitted by: Zhouyi Zhou PR: kern/111260 Discussed with: kib MFC after: 3 weeks --- sys/kern/kern_exec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index b4f3ccc080fc..09979493d570 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -513,6 +513,11 @@ do_execve(td, args, mac_p) goto interpret; } + /* + * NB: We unlock the vnode here because it is believed that none + * of the sv_copyout_strings/sv_fixup operations require the vnode. + */ + VOP_UNLOCK(imgp->vp, 0); /* * Copy out strings (args and env) and initialize stack base */ @@ -550,7 +555,6 @@ do_execve(td, args, mac_p) } /* close files on exec */ - VOP_UNLOCK(imgp->vp, 0); fdcloseexec(td); vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);