Commit e36c4e23 authored by Mike Marciniszyn's avatar Mike Marciniszyn Committed by Greg Kroah-Hartman

IB/hfi1: Add limit test for RC/UC send via loopback

commit 09ce351d upstream.

Fix potential memory corruption and panic in loopback for IB_WR_SEND
variants.

The code blindly assumes the posted length will fit in the fetched rwqe,
which is not a valid assumption.

Fix by adding a limit test, and triggering the appropriate send completion
and putting the QP in an error state.  This mimics the handling for
non-loopback QPs.

Fixes: 15703461 ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt")
Cc: <stable@vger.kernel.org> #v4.20+
Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
parent ff371bc8
...@@ -440,6 +440,8 @@ static void ruc_loopback(struct rvt_qp *sqp) ...@@ -440,6 +440,8 @@ static void ruc_loopback(struct rvt_qp *sqp)
goto op_err; goto op_err;
if (!ret) if (!ret)
goto rnr_nak; goto rnr_nak;
if (wqe->length > qp->r_len)
goto inv_err;
break; break;
case IB_WR_RDMA_WRITE_WITH_IMM: case IB_WR_RDMA_WRITE_WITH_IMM:
...@@ -607,7 +609,10 @@ static void ruc_loopback(struct rvt_qp *sqp) ...@@ -607,7 +609,10 @@ static void ruc_loopback(struct rvt_qp *sqp)
goto err; goto err;
inv_err: inv_err:
send_status = IB_WC_REM_INV_REQ_ERR; send_status =
sqp->ibqp.qp_type == IB_QPT_RC ?
IB_WC_REM_INV_REQ_ERR :
IB_WC_SUCCESS;
wc.status = IB_WC_LOC_QP_OP_ERR; wc.status = IB_WC_LOC_QP_OP_ERR;
goto err; goto err;
......
...@@ -425,6 +425,8 @@ static void qib_ruc_loopback(struct rvt_qp *sqp) ...@@ -425,6 +425,8 @@ static void qib_ruc_loopback(struct rvt_qp *sqp)
goto op_err; goto op_err;
if (!ret) if (!ret)
goto rnr_nak; goto rnr_nak;
if (wqe->length > qp->r_len)
goto inv_err;
break; break;
case IB_WR_RDMA_WRITE_WITH_IMM: case IB_WR_RDMA_WRITE_WITH_IMM:
...@@ -585,7 +587,10 @@ static void qib_ruc_loopback(struct rvt_qp *sqp) ...@@ -585,7 +587,10 @@ static void qib_ruc_loopback(struct rvt_qp *sqp)
goto err; goto err;
inv_err: inv_err:
send_status = IB_WC_REM_INV_REQ_ERR; send_status =
sqp->ibqp.qp_type == IB_QPT_RC ?
IB_WC_REM_INV_REQ_ERR :
IB_WC_SUCCESS;
wc.status = IB_WC_LOC_QP_OP_ERR; wc.status = IB_WC_LOC_QP_OP_ERR;
goto err; goto err;
......
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