]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
xfs: don't change inode mode if ACL update fails
authorDave Chinner <dchinner@redhat.com>
Mon, 9 Oct 2017 18:37:23 +0000 (11:37 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 11 Oct 2017 17:21:06 +0000 (10:21 -0700)
If we get ENOSPC half way through setting the ACL, the inode mode
can still be changed even though the ACL does not exist. Reorder the
operation to only change the mode of the inode if the ACL is set
correctly.

Whilst this does not fix the problem with crash consistency (that requires
attribute addition to be a deferred op) it does prevent ENOSPC and other
non-fatal errors setting an xattr to be handled sanely.

This fixes xfstests generic/449.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_acl.c

index 7034e17535dee2fbce449e72a4505341234a718e..3354140de07eb8aa2566c6c9254ad85e24a2a4bf 100644 (file)
@@ -247,6 +247,8 @@ xfs_set_mode(struct inode *inode, umode_t mode)
 int
 xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
+       umode_t mode;
+       bool set_mode = false;
        int error = 0;
 
        if (!acl)
@@ -257,16 +259,24 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
                return error;
 
        if (type == ACL_TYPE_ACCESS) {
-               umode_t mode;
-
                error = posix_acl_update_mode(inode, &mode, &acl);
                if (error)
                        return error;
-               error = xfs_set_mode(inode, mode);
-               if (error)
-                       return error;
+               set_mode = true;
        }
 
  set_acl:
-       return __xfs_set_acl(inode, acl, type);
+       error =  __xfs_set_acl(inode, acl, type);
+       if (error)
+               return error;
+
+       /*
+        * We set the mode after successfully updating the ACL xattr because the
+        * xattr update can fail at ENOSPC and we don't want to change the mode
+        * if the ACL update hasn't been applied.
+        */
+       if (set_mode)
+               error = xfs_set_mode(inode, mode);
+
+       return error;
 }