diff mbox

nfsd: Correct read access checking

Message ID 20130303090211.GA29550@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

ycnian@gmail.com March 3, 2013, 9:02 a.m. UTC
NFS4_SHARE_ACCESS_WRITE should not be tested in access_permit_read() for this
function just tests read permission, so remove it.

Signed-off-by: Yanchuan Nian <ycnian@gmail.com>
---
 fs/nfsd/nfs4state.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

J. Bruce Fields March 5, 2013, 9:10 p.m. UTC | #1
On Sun, Mar 03, 2013 at 05:02:11PM +0800, Yanchuan Nian wrote:
> NFS4_SHARE_ACCESS_WRITE should not be tested in access_permit_read() for this
> function just tests read permission, so remove it.
> 
> Signed-off-by: Yanchuan Nian <ycnian@gmail.com>
> ---
>  fs/nfsd/nfs4state.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 16d39c6..75c873d 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -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.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 16d39c6..75c873d 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -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