Author: kib
Date: Tue Dec 29 16:11:43 2015
New Revision: 292875
URL: https://svnweb.freebsd.org/changeset/base/292875

Log:
  MFC r292621:
  Keep devfs mount locked for the whole duration of the devfs_setattr(),
  and ensure that our dirent is instantiated.

Modified:
  stable/10/sys/fs/devfs/devfs_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- stable/10/sys/fs/devfs/devfs_vnops.c        Tue Dec 29 16:09:15 2015        
(r292874)
+++ stable/10/sys/fs/devfs/devfs_vnops.c        Tue Dec 29 16:11:43 2015        
(r292875)
@@ -1533,11 +1533,15 @@ devfs_setattr(struct vop_setattr_args *a
                return (EINVAL);
        }
 
+       error = devfs_populate_vp(vp);
+       if (error != 0)
+               return (error);
+
        de = vp->v_data;
        if (vp->v_type == VDIR)
                de = de->de_dir;
 
-       error = c = 0;
+       c = 0;
        if (vap->va_uid == (uid_t)VNOVAL)
                uid = de->de_uid;
        else
@@ -1550,8 +1554,8 @@ devfs_setattr(struct vop_setattr_args *a
                if ((ap->a_cred->cr_uid != de->de_uid) || uid != de->de_uid ||
                    (gid != de->de_gid && !groupmember(gid, ap->a_cred))) {
                        error = priv_check(td, PRIV_VFS_CHOWN);
-                       if (error)
-                               return (error);
+                       if (error != 0)
+                               goto ret;
                }
                de->de_uid = uid;
                de->de_gid = gid;
@@ -1561,8 +1565,8 @@ devfs_setattr(struct vop_setattr_args *a
        if (vap->va_mode != (mode_t)VNOVAL) {
                if (ap->a_cred->cr_uid != de->de_uid) {
                        error = priv_check(td, PRIV_VFS_ADMIN);
-                       if (error)
-                               return (error);
+                       if (error != 0)
+                               goto ret;
                }
                de->de_mode = vap->va_mode;
                c = 1;
@@ -1571,7 +1575,7 @@ devfs_setattr(struct vop_setattr_args *a
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
                error = vn_utimes_perm(vp, vap, ap->a_cred, td);
                if (error != 0)
-                       return (error);
+                       goto ret;
                if (vap->va_atime.tv_sec != VNOVAL) {
                        if (vp->v_type == VCHR)
                                vp->v_rdev->si_atime = vap->va_atime;
@@ -1593,7 +1597,10 @@ devfs_setattr(struct vop_setattr_args *a
                else
                        vfs_timestamp(&de->de_mtime);
        }
-       return (0);
+
+ret:
+       sx_xunlock(&VFSTODEVFS(vp->v_mount)->dm_lock);
+       return (error);
 }
 
 #ifdef MAC
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to