Commit 61433af5 authored by Chuck Lever's avatar Chuck Lever Committed by Anna Schumaker

xprtrdma: Throw away reply when version is unrecognized

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: 59aa1f9a ("xprtrdma: Properly handle RDMA_ERROR ... ")
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 2b4f8923
...@@ -1248,6 +1248,9 @@ rpcrdma_reply_handler(struct work_struct *work) ...@@ -1248,6 +1248,9 @@ rpcrdma_reply_handler(struct work_struct *work)
p++; /* credits */ p++; /* credits */
proc = *p++; proc = *p++;
if (vers != rpcrdma_version)
goto out_badversion;
if (rpcrdma_is_bcall(r_xprt, rep, xid, proc)) if (rpcrdma_is_bcall(r_xprt, rep, xid, proc))
return; return;
...@@ -1280,8 +1283,6 @@ rpcrdma_reply_handler(struct work_struct *work) ...@@ -1280,8 +1283,6 @@ rpcrdma_reply_handler(struct work_struct *work)
} }
xprt->reestablish_timeout = 0; xprt->reestablish_timeout = 0;
if (vers != rpcrdma_version)
goto out_badversion;
switch (proc) { switch (proc) {
case rdma_msg: case rdma_msg:
...@@ -1321,17 +1322,15 @@ rpcrdma_reply_handler(struct work_struct *work) ...@@ -1321,17 +1322,15 @@ rpcrdma_reply_handler(struct work_struct *work)
} }
return; 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: out_badversion:
dprintk("RPC: %s: invalid version %d\n", dprintk("RPC: %s: invalid version %d\n",
__func__, be32_to_cpu(vers)); __func__, be32_to_cpu(vers));
status = -EIO; goto repost;
r_xprt->rx_stats.bad_reply_count++;
goto out;
/* 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: out_badheader:
dprintk("RPC: %5u %s: invalid rpcrdma reply (type %u)\n", dprintk("RPC: %5u %s: invalid rpcrdma reply (type %u)\n",
rqst->rq_task->tk_pid, __func__, be32_to_cpu(proc)); rqst->rq_task->tk_pid, __func__, be32_to_cpu(proc));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment