]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.19.7/nfsd4-fix-read-permission-checking.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.19.7 / nfsd4-fix-read-permission-checking.patch
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
5
6 From: "J. Bruce Fields" <bfields@redhat.com>
7
8 commit 6e4891dc289cd191d46ab7ba1dcb29646644f9ca upstream.
9
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
13 stateid.
14
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>
18
19 ---
20 fs/nfsd/nfs4xdr.c | 12 ++++++++----
21 1 file changed, 8 insertions(+), 4 deletions(-)
22
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;
31 struct raparms *ra;
32 __be32 *p;
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);
36
37 - if (!read->rd_filp) {
38 + if (read->rd_filp)
39 + err = nfsd_permission(resp->rqstp, fhp->fh_export,
40 + fhp->fh_dentry,
41 + NFSD_MAY_READ|NFSD_MAY_OWNER_OVERRIDE);
42 + else
43 err = nfsd_get_tmp_read_open(resp->rqstp, read->rd_fhp,
44 &file, &ra);
45 - if (err)
46 - goto err_truncate;
47 - }
48 + if (err)
49 + goto err_truncate;
50
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);