From owner-svn-src-head@FreeBSD.ORG Mon Jul 7 14:03:31 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0850B5F1; Mon, 7 Jul 2014 14:03:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EA10528E9; Mon, 7 Jul 2014 14:03:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s67E3UHo000588; Mon, 7 Jul 2014 14:03:30 GMT (envelope-from mjg@svn.freebsd.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s67E3Unc000587; Mon, 7 Jul 2014 14:03:30 GMT (envelope-from mjg@svn.freebsd.org) Message-Id: <201407071403.s67E3Unc000587@svn.freebsd.org> From: Mateusz Guzik Date: Mon, 7 Jul 2014 14:03:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268365 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jul 2014 14:03:31 -0000 Author: mjg Date: Mon Jul 7 14:03:30 2014 New Revision: 268365 URL: http://svnweb.freebsd.org/changeset/base/268365 Log: Don't call crdup nor uifind under vnode lock. A locked vnode can get into the way of satisyfing malloc with M_WATOK. This is a fixup to r268087. Suggested by: kib MFC after: 1 week Modified: head/sys/kern/kern_exec.c Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Mon Jul 7 11:52:22 2014 (r268364) +++ head/sys/kern/kern_exec.c Mon Jul 7 14:03:30 2014 (r268365) @@ -718,11 +718,11 @@ interpret: VOP_UNLOCK(imgp->vp, 0); setugidsafety(td); error = fdcheckstd(td); - vn_lock(imgp->vp, LK_SHARED | LK_RETRY); if (error != 0) goto done1; newcred = crdup(oldcred); euip = uifind(attr.va_uid); + vn_lock(imgp->vp, LK_SHARED | LK_RETRY); PROC_LOCK(p); /* * Set the new credentials. @@ -766,7 +766,9 @@ interpret: if (oldcred->cr_svuid != oldcred->cr_uid || oldcred->cr_svgid != oldcred->cr_gid) { PROC_UNLOCK(p); + VOP_UNLOCK(imgp->vp, 0); newcred = crdup(oldcred); + vn_lock(imgp->vp, LK_SHARED | LK_RETRY); PROC_LOCK(p); change_svuid(newcred, newcred->cr_uid); change_svgid(newcred, newcred->cr_gid); @@ -843,6 +845,7 @@ interpret: SDT_PROBE(proc, kernel, , exec__success, args->fname, 0, 0, 0, 0); + VOP_UNLOCK(imgp->vp, 0); done1: /* * Free any resources malloc'd earlier that we didn't use. @@ -851,7 +854,6 @@ done1: uifree(euip); if (newcred != NULL) crfree(oldcred); - VOP_UNLOCK(imgp->vp, 0); /* * Handle deferred decrement of ref counts.