diff options
author | Eryu Guan <guaneryu@gmail.com> | 2016-08-02 07:58:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-07 10:03:31 -0400 |
commit | 337684a1746f93ae107e05d90977b070bb7e39d8 (patch) | |
tree | 1922204c16c1b9a8a54cecb8d3512f2b46a2695b | |
parent | fe64f3283fb315e3d8f2b78785a86904a852ca82 (diff) |
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>
-rw-r--r-- | fs/gfs2/inode.c | 2 | ||||
-rw-r--r-- | fs/namei.c | 2 | ||||
-rw-r--r-- | fs/utimes.c | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl.c | 2 |
4 files changed, 5 insertions, 4 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index e0621cacf134..e4da0ecd3285 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -1800,7 +1800,7 @@ int gfs2_permission(struct inode *inode, int mask) | |||
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode)) | 1802 | if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode)) |
1803 | error = -EACCES; | 1803 | error = -EPERM; |
1804 | else | 1804 | else |
1805 | error = generic_permission(inode, mask); | 1805 | error = generic_permission(inode, mask); |
1806 | if (gfs2_holder_initialized(&i_gh)) | 1806 | if (gfs2_holder_initialized(&i_gh)) |
diff --git a/fs/namei.c b/fs/namei.c index c386a329ab20..adb04146df09 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -410,7 +410,7 @@ int __inode_permission(struct inode *inode, int mask) | |||
410 | * Nobody gets write access to an immutable file. | 410 | * Nobody gets write access to an immutable file. |
411 | */ | 411 | */ |
412 | if (IS_IMMUTABLE(inode)) | 412 | if (IS_IMMUTABLE(inode)) |
413 | return -EACCES; | 413 | return -EPERM; |
414 | 414 | ||
415 | /* | 415 | /* |
416 | * Updating mtime will likely cause i_uid and i_gid to be | 416 | * Updating mtime will likely cause i_uid and i_gid to be |
diff --git a/fs/utimes.c b/fs/utimes.c index 85c40f4f373d..794f5f5b1fb5 100644 --- a/fs/utimes.c +++ b/fs/utimes.c | |||
@@ -92,10 +92,11 @@ static int utimes_common(struct path *path, struct timespec *times) | |||
92 | * then we need to check permissions, because | 92 | * then we need to check permissions, because |
93 | * inode_change_ok() won't do it. | 93 | * inode_change_ok() won't do it. |
94 | */ | 94 | */ |
95 | error = -EACCES; | 95 | error = -EPERM; |
96 | if (IS_IMMUTABLE(inode)) | 96 | if (IS_IMMUTABLE(inode)) |
97 | goto mnt_drop_write_and_out; | 97 | goto mnt_drop_write_and_out; |
98 | 98 | ||
99 | error = -EACCES; | ||
99 | if (!inode_owner_or_capable(inode)) { | 100 | if (!inode_owner_or_capable(inode)) { |
100 | error = inode_permission(inode, MAY_WRITE); | 101 | error = inode_permission(inode, MAY_WRITE); |
101 | if (error) | 102 | if (error) |
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index cf46658392ce..96a70fd1f5d6 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
@@ -232,7 +232,7 @@ xfs_open_by_handle( | |||
232 | } | 232 | } |
233 | 233 | ||
234 | if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) { | 234 | if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) { |
235 | error = -EACCES; | 235 | error = -EPERM; |
236 | goto out_dput; | 236 | goto out_dput; |
237 | } | 237 | } |
238 | 238 | ||