Skip to content

Commit 09ce351

Browse files
mmarcinijgunthorpe
authored andcommitted
IB/hfi1: Add limit test for RC/UC send via loopback
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: 1570346 ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt") Cc: <stable@vger.kernel.org> #v4.20+ Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 7709b0d commit 09ce351

File tree

1 file changed

+6
-1
lines changed
  • drivers/infiniband/sw/rdmavt

1 file changed

+6
-1
lines changed

drivers/infiniband/sw/rdmavt/qp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,8 @@ void rvt_ruc_loopback(struct rvt_qp *sqp)
29102910
goto op_err;
29112911
if (!ret)
29122912
goto rnr_nak;
2913+
if (wqe->length > qp->r_len)
2914+
goto inv_err;
29132915
break;
29142916

29152917
case IB_WR_RDMA_WRITE_WITH_IMM:
@@ -3078,7 +3080,10 @@ void rvt_ruc_loopback(struct rvt_qp *sqp)
30783080
goto err;
30793081

30803082
inv_err:
3081-
send_status = IB_WC_REM_INV_REQ_ERR;
3083+
send_status =
3084+
sqp->ibqp.qp_type == IB_QPT_RC ?
3085+
IB_WC_REM_INV_REQ_ERR :
3086+
IB_WC_SUCCESS;
30823087
wc.status = IB_WC_LOC_QP_OP_ERR;
30833088
goto err;
30843089

0 commit comments

Comments
 (0)