fs: return EPERM on immutable inode

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>

authored by Eryu Guan and committed by Linus Torvalds 337684a1 fe64f328

Changed files
+5 -4
fs
+1 -1
fs/gfs2/inode.c
··· 1800 1800 } 1801 1801 1802 1802 if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode)) 1803 - error = -EACCES; 1803 + error = -EPERM; 1804 1804 else 1805 1805 error = generic_permission(inode, mask); 1806 1806 if (gfs2_holder_initialized(&i_gh))
+1 -1
fs/namei.c
··· 410 410 * Nobody gets write access to an immutable file. 411 411 */ 412 412 if (IS_IMMUTABLE(inode)) 413 - return -EACCES; 413 + return -EPERM; 414 414 415 415 /* 416 416 * Updating mtime will likely cause i_uid and i_gid to be
+2 -1
fs/utimes.c
··· 92 92 * then we need to check permissions, because 93 93 * inode_change_ok() won't do it. 94 94 */ 95 - error = -EACCES; 95 + error = -EPERM; 96 96 if (IS_IMMUTABLE(inode)) 97 97 goto mnt_drop_write_and_out; 98 98 99 + error = -EACCES; 99 100 if (!inode_owner_or_capable(inode)) { 100 101 error = inode_permission(inode, MAY_WRITE); 101 102 if (error)
+1 -1
fs/xfs/xfs_ioctl.c
··· 232 232 } 233 233 234 234 if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) { 235 - error = -EACCES; 235 + error = -EPERM; 236 236 goto out_dput; 237 237 } 238 238