linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: return EPERM on immutable inode
@ 2016-04-05 13:28 Eryu Guan
  2016-04-05 20:44 ` Dave Chinner
  2016-04-06  3:44 ` [PATCH v2] " Eryu Guan
  0 siblings, 2 replies; 3+ messages in thread
From: Eryu Guan @ 2016-04-05 13:28 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Eryu Guan, Steven Whitehouse, Bob Peterson, Alexander Viro,
	Dave Chinner, supporter:XFS FILESYSTEM,
	open list:GFS2 FILE SYSTEM, open list

In most cases, EPERM is returned on immutable inode, and there're only
a few places returning EACCES. And EPERM looks more reasonable to me.

So converting all EACCES to EPERM on immutable inode.

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
---

I noticed this when running LTP on overlayfs, setxattr03 failed due to
unexpected EACCES on immutable inode.

 fs/gfs2/inode.c    | 2 +-
 fs/namei.c         | 2 +-
 fs/utimes.c        | 3 ++-
 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 bb30f9a..4c68d91 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1757,7 +1757,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 (unlock)
diff --git a/fs/namei.c b/fs/namei.c
index 1d9ca2d..7f4a40a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -408,7 +408,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;
 	}
 
 	retval = do_inode_permission(inode, mask);
diff --git a/fs/utimes.c b/fs/utimes.c
index 85c40f4..794f5f5 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -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)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index bcb6c19..4c4c58f 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -232,7 +232,7 @@ xfs_open_by_handle(
 	}
 
 	if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
-		error = -EACCES;
+		error = -EPERM;
 		goto out_dput;
 	}
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: return EPERM on immutable inode
  2016-04-05 13:28 [PATCH] fs: return EPERM on immutable inode Eryu Guan
@ 2016-04-05 20:44 ` Dave Chinner
  2016-04-06  3:44 ` [PATCH v2] " Eryu Guan
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2016-04-05 20:44 UTC (permalink / raw)
  To: Eryu Guan
  Cc: linux-fsdevel, Steven Whitehouse, Bob Peterson, Alexander Viro,
	supporter:XFS FILESYSTEM, open list:GFS2 FILE SYSTEM, open list

On Tue, Apr 05, 2016 at 09:28:10PM +0800, Eryu Guan wrote:
> In most cases, EPERM is returned on immutable inode, and there're only
> a few places returning EACCES. And EPERM looks more reasonable to me.
> 
> So converting all EACCES to EPERM on immutable inode.
> 
> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
> ---
> 
> I noticed this when running LTP on overlayfs, setxattr03 failed due to
> unexpected EACCES on immutable inode.

This should be in the commit message itself, rather than "EPERM
looks more reasonable".

Other than that, change seems fine to me.

Acked-by: Dave Chinner <dchinner@redhat.com>
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] fs: return EPERM on immutable inode
  2016-04-05 13:28 [PATCH] fs: return EPERM on immutable inode Eryu Guan
  2016-04-05 20:44 ` Dave Chinner
@ 2016-04-06  3:44 ` Eryu Guan
  1 sibling, 0 replies; 3+ messages in thread
From: Eryu Guan @ 2016-04-06  3:44 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Eryu Guan, Steven Whitehouse, Bob Peterson, Alexander Viro,
	Dave Chinner, supporter:XFS FILESYSTEM,
	open list:GFS2 FILE SYSTEM, open list

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>
---
v2:
- update commit message to include the background on noticing this issue

 fs/gfs2/inode.c    | 2 +-
 fs/namei.c         | 2 +-
 fs/utimes.c        | 3 ++-
 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 bb30f9a..4c68d91 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1757,7 +1757,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 (unlock)
diff --git a/fs/namei.c b/fs/namei.c
index 1d9ca2d..7f4a40a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -408,7 +408,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;
 	}
 
 	retval = do_inode_permission(inode, mask);
diff --git a/fs/utimes.c b/fs/utimes.c
index 85c40f4..794f5f5 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -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)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index bcb6c19..4c4c58f 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -232,7 +232,7 @@ xfs_open_by_handle(
 	}
 
 	if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
-		error = -EACCES;
+		error = -EPERM;
 		goto out_dput;
 	}
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-06  3:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-05 13:28 [PATCH] fs: return EPERM on immutable inode Eryu Guan
2016-04-05 20:44 ` Dave Chinner
2016-04-06  3:44 ` [PATCH v2] " Eryu Guan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).