[PATCH] nfsd: remove unnecessary permission checking in nfsv4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yanchuan Nian <ycnian@xxxxxxxxx>

Since read can use stateid's from opens that only requested write access,
the value returned from access_permit_read() will always be true. It's not
necessary to check read permission in nfsv4.

Signed-off-by: Yanchuan Nian <ycnian@xxxxxxxxx>
---
 fs/nfsd/nfs4state.c |   16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 2e27430..42824cd 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3287,14 +3287,6 @@ STALE_STATEID(stateid_t *stateid, struct nfsd_net *nn)
 }
 
 static inline int
-access_permit_read(struct nfs4_ol_stateid *stp)
-{
-	return test_access(NFS4_SHARE_ACCESS_READ, stp) ||
-		test_access(NFS4_SHARE_ACCESS_BOTH, stp) ||
-		test_access(NFS4_SHARE_ACCESS_WRITE, stp);
-}
-
-static inline int
 access_permit_write(struct nfs4_ol_stateid *stp)
 {
 	return test_access(NFS4_SHARE_ACCESS_WRITE, stp) ||
@@ -3304,17 +3296,13 @@ access_permit_write(struct nfs4_ol_stateid *stp)
 static
 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags)
 {
-        __be32 status = nfserr_openmode;
+	__be32 status = nfs_ok;
 
 	/* For lock stateid's, we test the parent open, not the lock: */
 	if (stp->st_openstp)
 		stp = stp->st_openstp;
 	if ((flags & WR_STATE) && !access_permit_write(stp))
-                goto out;
-	if ((flags & RD_STATE) && !access_permit_read(stp))
-                goto out;
-	status = nfs_ok;
-out:
+		status = nfserr_openmode;
 	return status;
 }
 
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux