Skip to content

Commit

Permalink
SUNRPC: Don't try to parse incomplete RPC messages
Browse files Browse the repository at this point in the history
If the copy of the RPC reply into our buffers did not complete, and
we could end up with a truncated message. In that case, just resend
the call.

Fixes: a0584ee ("SUNRPC: Use struct xdr_stream when decoding...")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
  • Loading branch information
Trond Myklebust authored and Anna Schumaker committed Sep 20, 2019
1 parent f925ab9 commit 9ba8288
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,7 @@ call_decode(struct rpc_task *task)
struct rpc_clnt *clnt = task->tk_client;
struct rpc_rqst *req = task->tk_rqstp;
struct xdr_stream xdr;
int err;

dprint_status(task);

Expand All @@ -2487,6 +2488,15 @@ call_decode(struct rpc_task *task)
* before it changed req->rq_reply_bytes_recvd.
*/
smp_rmb();

/*
* Did we ever call xprt_complete_rqst()? If not, we should assume
* the message is incomplete.
*/
err = -EAGAIN;
if (!req->rq_reply_bytes_recvd)
goto out;

req->rq_rcv_buf.len = req->rq_private_buf.len;

/* Check that the softirq receive buffer is valid */
Expand All @@ -2495,7 +2505,9 @@ call_decode(struct rpc_task *task)

xdr_init_decode(&xdr, &req->rq_rcv_buf,
req->rq_rcv_buf.head[0].iov_base, req);
switch (rpc_decode_header(task, &xdr)) {
err = rpc_decode_header(task, &xdr);
out:
switch (err) {
case 0:
task->tk_action = rpc_exit_task;
task->tk_status = rpcauth_unwrap_resp(task, &xdr);
Expand Down

0 comments on commit 9ba8288

Please sign in to comment.