fs: return EPERM on immutable inode
authorEryu Guan <guaneryu@gmail.com>
Tue, 2 Aug 2016 11:58:28 +0000 (19:58 +0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 7 Aug 2016 14:03:31 +0000 (10:03 -0400)
In most cases, EPERM is returned on immutable inode, and there're only a
few places returning EACCES. I noticed this when running LTP on
overlayfs, setxattr03 failed due to unexpected EACCES on immutable
inode.

So converting all EACCES to EPERM on immutable inode.

Acked-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/gfs2/inode.c
fs/namei.c
fs/utimes.c
fs/xfs/xfs_ioctl.c

index e0621ca..e4da0ec 100644 (file)
@@ -1800,7 +1800,7 @@ int gfs2_permission(struct inode *inode, int mask)
        }
 
        if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
-               error = -EACCES;
+               error = -EPERM;
        else
                error = generic_permission(inode, mask);
        if (gfs2_holder_initialized(&i_gh))
index c386a32..adb0414 100644 (file)
@@ -410,7 +410,7 @@ int __inode_permission(struct inode *inode, int mask)
                 * Nobody gets write access to an immutable file.
                 */
                if (IS_IMMUTABLE(inode))
-                       return -EACCES;
+                       return -EPERM;
 
                /*
                 * Updating mtime will likely cause i_uid and i_gid to be
index 85c40f4..794f5f5 100644 (file)
@@ -92,10 +92,11 @@ static int utimes_common(struct path *path, struct timespec *times)
                 * then we need to check permissions, because
                 * inode_change_ok() won't do it.
                 */
-               error = -EACCES;
+               error = -EPERM;
                 if (IS_IMMUTABLE(inode))
                        goto mnt_drop_write_and_out;
 
+               error = -EACCES;
                if (!inode_owner_or_capable(inode)) {
                        error = inode_permission(inode, MAY_WRITE);
                        if (error)
index cf46658..96a70fd 100644 (file)
@@ -232,7 +232,7 @@ xfs_open_by_handle(
        }
 
        if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
-               error = -EACCES;
+               error = -EPERM;
                goto out_dput;
        }