Skip to contentSkip to conversation

nfsd: Correct read access checking

PATCH In review Yanchuan Nian 2 participants 2 messages Mar 3, 2013 – Mar 5, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: Correct read access checking

NFS4_SHARE_ACCESS_WRITE should not be tested in access_permit_read() for this function just tests read permission, so remove it.

---
 fs/nfsd/nfs4state.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/nfs4state.c +1 -2
index 16d39c6..75c873d 100644
@@ -3322,8 +3322,7 @@ 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);
+		test_access(NFS4_SHARE_ACCESS_BOTH, stp);
 }
 
 static inline int
Signature · 1 line
1.8.0.1
#1 lore raw
Quoted 13 lines · Yanchuan Nian

NFS4_SHARE_ACCESS_WRITE should not be tested in access_permit_read() for this function just tests read permission, so remove it.

---
 fs/nfsd/nfs4state.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/nfs4state.c +0 -0
index 16d39c6..75c873d 100644

fs/nfsd/nfs4state.c static inline int · line 3326

Quoted 7 lines
fs/nfsd/nfs4state.c +1 -2
@@ -3322,8 +3322,7 @@ 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);
+		test_access(NFS4_SHARE_ACCESS_BOTH, stp);
 }

This was introduced by a patch from 2005:

[PATCH] nfsd4: allow read on open for write

The rfc recommends allowing read using stateid's from opens that only requested write access, as clients may in some cases be unable to write without doing reads.

So I think it's correct.

That said, I don't understand why we still have this function at all:
can it ever return anything other than true?

--b.