Author: mjg
Date: Sun Aug 17 06:58:14 2014
New Revision: 270087
URL: http://svnweb.freebsd.org/changeset/base/270087

Log:
  MFC r268365:
  
  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.

Modified:
  stable/10/sys/kern/kern_exec.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_exec.c
==============================================================================
--- stable/10/sys/kern/kern_exec.c      Sun Aug 17 06:56:22 2014        
(r270086)
+++ stable/10/sys/kern/kern_exec.c      Sun Aug 17 06:58:14 2014        
(r270087)
@@ -721,11 +721,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.
@@ -769,7 +769,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);
@@ -846,6 +848,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.
@@ -854,7 +857,6 @@ done1:
                uifree(euip);
        if (newcred != NULL)
                crfree(oldcred);
-       VOP_UNLOCK(imgp->vp, 0);
 
        /*
         * Handle deferred decrement of ref counts.
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to