Skip to content

Commit 337684a

Browse files
guaneryutorvalds
authored andcommitted
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>
1 parent fe64f32 commit 337684a

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

fs/gfs2/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ int gfs2_permission(struct inode *inode, int mask)
18001800
}
18011801

18021802
if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
1803-
error = -EACCES;
1803+
error = -EPERM;
18041804
else
18051805
error = generic_permission(inode, mask);
18061806
if (gfs2_holder_initialized(&i_gh))

fs/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ int __inode_permission(struct inode *inode, int mask)
410410
* Nobody gets write access to an immutable file.
411411
*/
412412
if (IS_IMMUTABLE(inode))
413-
return -EACCES;
413+
return -EPERM;
414414

415415
/*
416416
* Updating mtime will likely cause i_uid and i_gid to be

fs/utimes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ static int utimes_common(struct path *path, struct timespec *times)
9292
* then we need to check permissions, because
9393
* inode_change_ok() won't do it.
9494
*/
95-
error = -EACCES;
95+
error = -EPERM;
9696
if (IS_IMMUTABLE(inode))
9797
goto mnt_drop_write_and_out;
9898

99+
error = -EACCES;
99100
if (!inode_owner_or_capable(inode)) {
100101
error = inode_permission(inode, MAY_WRITE);
101102
if (error)

fs/xfs/xfs_ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ xfs_open_by_handle(
232232
}
233233

234234
if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
235-
error = -EACCES;
235+
error = -EPERM;
236236
goto out_dput;
237237
}
238238

0 commit comments

Comments
 (0)