Skip to content

Commit

Permalink
xprtrdma: Throw away reply when version is unrecognized
Browse files Browse the repository at this point in the history
A reply with an unrecognized value in the version field means the
transport header is potentially garbled and therefore all the fields
are untrustworthy.

Fixes: 59aa1f9 ("xprtrdma: Properly handle RDMA_ERROR ... ")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
  • Loading branch information
Chuck Lever authored and Anna Schumaker committed Nov 17, 2017
1 parent 2b4f892 commit 61433af
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions net/sunrpc/xprtrdma/rpc_rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,9 @@ rpcrdma_reply_handler(struct work_struct *work)
p++; /* credits */
proc = *p++;

if (vers != rpcrdma_version)
goto out_badversion;

if (rpcrdma_is_bcall(r_xprt, rep, xid, proc))
return;

Expand Down Expand Up @@ -1280,8 +1283,6 @@ rpcrdma_reply_handler(struct work_struct *work)
}

xprt->reestablish_timeout = 0;
if (vers != rpcrdma_version)
goto out_badversion;

switch (proc) {
case rdma_msg:
Expand Down Expand Up @@ -1321,17 +1322,15 @@ rpcrdma_reply_handler(struct work_struct *work)
}
return;

/* If the incoming reply terminated a pending RPC, the next
* RPC call will post a replacement receive buffer as it is
* being marshaled.
*/
out_badversion:
dprintk("RPC: %s: invalid version %d\n",
__func__, be32_to_cpu(vers));
status = -EIO;
r_xprt->rx_stats.bad_reply_count++;
goto out;
goto repost;

/* If the incoming reply terminated a pending RPC, the next
* RPC call will post a replacement receive buffer as it is
* being marshaled.
*/
out_badheader:
dprintk("RPC: %5u %s: invalid rpcrdma reply (type %u)\n",
rqst->rq_task->tk_pid, __func__, be32_to_cpu(proc));
Expand Down

0 comments on commit 61433af

Please sign in to comment.