diff options
author | Benjamin Coddington <bcodding@redhat.com> | 2015-11-20 09:55:30 -0500 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-11-23 22:03:15 -0500 |
commit | 38b7631fbe42e6e247e9fc9879f961b14a687e3b (patch) | |
tree | edcf8b437182b980a936bc11a46a292c31173c7f /net/sunrpc | |
parent | c68a027c05709330fe5b2f50c50d5fa02124b5d8 (diff) |
nfs4: limit callback decoding to received bytes
A truncated cb_compound request will cause the client to decode null or
data from a previous callback for nfs4.1 backchannel case, or uninitialized
data for the nfs4.0 case. This is because the path through
svc_process_common() advances the request's iov_base and decrements iov_len
without adjusting the overall xdr_buf's len field. That causes
xdr_init_decode() to set up the xdr_stream with an incorrect length in
nfs4_callback_compound().
Fixing this for the nfs4.1 backchannel case first requires setting the
correct iov_len and page_len based on the length of received data in the
same manner as the nfs4.0 case.
Then the request's xdr_buf length can be adjusted for both cases based upon
the remaining iov_len and page_len.
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/backchannel_rqst.c | 8 | ||||
-rw-r--r-- | net/sunrpc/svc.c | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c index 229956bf8457..95f82d8d4888 100644 --- a/net/sunrpc/backchannel_rqst.c +++ b/net/sunrpc/backchannel_rqst.c | |||
@@ -353,12 +353,20 @@ void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied) | |||
353 | { | 353 | { |
354 | struct rpc_xprt *xprt = req->rq_xprt; | 354 | struct rpc_xprt *xprt = req->rq_xprt; |
355 | struct svc_serv *bc_serv = xprt->bc_serv; | 355 | struct svc_serv *bc_serv = xprt->bc_serv; |
356 | struct xdr_buf *rq_rcv_buf = &req->rq_rcv_buf; | ||
356 | 357 | ||
357 | spin_lock(&xprt->bc_pa_lock); | 358 | spin_lock(&xprt->bc_pa_lock); |
358 | list_del(&req->rq_bc_pa_list); | 359 | list_del(&req->rq_bc_pa_list); |
359 | xprt_dec_alloc_count(xprt, 1); | 360 | xprt_dec_alloc_count(xprt, 1); |
360 | spin_unlock(&xprt->bc_pa_lock); | 361 | spin_unlock(&xprt->bc_pa_lock); |
361 | 362 | ||
363 | if (copied <= rq_rcv_buf->head[0].iov_len) { | ||
364 | rq_rcv_buf->head[0].iov_len = copied; | ||
365 | rq_rcv_buf->page_len = 0; | ||
366 | } else { | ||
367 | rq_rcv_buf->page_len = copied - rq_rcv_buf->head[0].iov_len; | ||
368 | } | ||
369 | |||
362 | req->rq_private_buf.len = copied; | 370 | req->rq_private_buf.len = copied; |
363 | set_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state); | 371 | set_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state); |
364 | 372 | ||
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index bc5b7b5032ca..7fccf9675df8 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -1363,6 +1363,7 @@ bc_svc_process(struct svc_serv *serv, struct rpc_rqst *req, | |||
1363 | memcpy(&rqstp->rq_addr, &req->rq_xprt->addr, rqstp->rq_addrlen); | 1363 | memcpy(&rqstp->rq_addr, &req->rq_xprt->addr, rqstp->rq_addrlen); |
1364 | memcpy(&rqstp->rq_arg, &req->rq_rcv_buf, sizeof(rqstp->rq_arg)); | 1364 | memcpy(&rqstp->rq_arg, &req->rq_rcv_buf, sizeof(rqstp->rq_arg)); |
1365 | memcpy(&rqstp->rq_res, &req->rq_snd_buf, sizeof(rqstp->rq_res)); | 1365 | memcpy(&rqstp->rq_res, &req->rq_snd_buf, sizeof(rqstp->rq_res)); |
1366 | rqstp->rq_arg.len = req->rq_private_buf.len; | ||
1366 | 1367 | ||
1367 | /* reset result send buffer "put" position */ | 1368 | /* reset result send buffer "put" position */ |
1368 | resv->iov_len = 0; | 1369 | resv->iov_len = 0; |