1 From 6e4891dc289cd191d46ab7ba1dcb29646644f9ca Mon Sep 17 00:00:00 2001
2 From: "J. Bruce Fields" <bfields@redhat.com>
3 Date: Fri, 3 Apr 2015 17:19:41 -0400
4 Subject: nfsd4: fix READ permission checking
6 From: "J. Bruce Fields" <bfields@redhat.com>
8 commit 6e4891dc289cd191d46ab7ba1dcb29646644f9ca upstream.
10 In the case we already have a struct file (derived from a stateid), we
11 still need to do permission-checking; otherwise an unauthorized user
12 could gain access to a file by sniffing or guessing somebody else's
15 Fixes: dc97618ddda9 "nfsd4: separate splice and readv cases"
16 Signed-off-by: J. Bruce Fields <bfields@redhat.com>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 fs/nfsd/nfs4xdr.c | 12 ++++++++----
21 1 file changed, 8 insertions(+), 4 deletions(-)
23 --- a/fs/nfsd/nfs4xdr.c
24 +++ b/fs/nfsd/nfs4xdr.c
25 @@ -3246,6 +3246,7 @@ nfsd4_encode_read(struct nfsd4_compoundr
26 unsigned long maxcount;
27 struct xdr_stream *xdr = &resp->xdr;
28 struct file *file = read->rd_filp;
29 + struct svc_fh *fhp = read->rd_fhp;
30 int starting_len = xdr->buf->len;
33 @@ -3269,12 +3270,15 @@ nfsd4_encode_read(struct nfsd4_compoundr
34 maxcount = min_t(unsigned long, maxcount, (xdr->buf->buflen - xdr->buf->len));
35 maxcount = min_t(unsigned long, maxcount, read->rd_length);
37 - if (!read->rd_filp) {
39 + err = nfsd_permission(resp->rqstp, fhp->fh_export,
41 + NFSD_MAY_READ|NFSD_MAY_OWNER_OVERRIDE);
43 err = nfsd_get_tmp_read_open(resp->rqstp, read->rd_fhp,
51 if (file->f_op->splice_read && test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags))
52 err = nfsd4_encode_splice_read(resp, read, file, maxcount);