提交 fc3f15c6 编写于 作者: M Mike Marciniszyn 提交者: Greg Kroah-Hartman

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

commit 09ce351dff8e7636af0beb72cd4a86c3904a0500 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: 15703461533a ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt")
Cc: <stable@vger.kernel.org> #v4.20+
Reviewed-by: NMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: NMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NMike Marciniszyn <mike.marciniszyn@intel.com>
上级 29706d59
......@@ -278,6 +278,8 @@ static void ruc_loopback(struct rvt_qp *sqp)
goto op_err;
if (!ret)
goto rnr_nak;
if (wqe->length > qp->r_len)
goto inv_err;
break;
case IB_WR_RDMA_WRITE_WITH_IMM:
......@@ -445,7 +447,10 @@ static void ruc_loopback(struct rvt_qp *sqp)
goto 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;
goto err;
......
......@@ -274,6 +274,8 @@ static void qib_ruc_loopback(struct rvt_qp *sqp)
goto op_err;
if (!ret)
goto rnr_nak;
if (wqe->length > qp->r_len)
goto inv_err;
break;
case IB_WR_RDMA_WRITE_WITH_IMM:
......@@ -434,7 +436,10 @@ static void qib_ruc_loopback(struct rvt_qp *sqp)
goto 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;
goto err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册