RDMA/rxe: Check PDs for memory window binds
Subsystems (2)
PATCH v2 1/1 RDMA/rxe: Check PDs for memory window binds
The IBTA Software Transport Verbs specification requires the QP, Memory Window and Memory Region for a Bind Memory Window operation to belong to the same HCA and protection domain.
rxe only checked the QP and MW protection domain for type 2 MWs. Move the QP/MW PD check to the common bind path and also reject binding an MW to an MR from a different PD.
Invalid bind requests continue to fail with IB_WC_MW_BIND_ERR.
--- drivers/infiniband/sw/rxe/rxe_mw.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/infiniband/sw/rxe/rxe_mw.c +12 -8
@@ -72,13 +72,6 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe,return -EINVAL ; } -/* C10-72 */ -if (unlikely (qp->pd !=to_rpd (mw->ibmw.pd))) { -rxe_dbg_mw (mw, -"attempt to bind type 2 MW with qp with different PD\n" ); -return -EINVAL ; - } -/* o10-37.2.40 */ if (unlikely (!mr || wqe->wr.wr.mw.length ==0 )) { rxe_dbg_mw(mw,
@@ -87,10 +80,21 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, } } -/* remaining checks only apply to a nonzero MR */ +/* C10-72 */ +if (unlikely (qp->pd !=rxe_mw_pd (mw))) { +rxe_dbg_mw (mw,"attempt to bind MW with qp with different PD\n" ); +return -EINVAL ; + } +if (!mr)return 0 ; +/* remaining checks only apply to a nonzero MR */ +if (unlikely (qp->pd !=mr_pd (mr))) { +rxe_dbg_mw (mw,"attempt to bind MW/QP to MR with different PD\n" ); +return -EINVAL ; + } +if (unlikely (mr->access &IB_ZERO_BASED )) {rxe_dbg_mw (mw,"attempt to bind MW to zero based MR\n" );return -EINVAL ;
Signature · 1 line
2.51.0
Quoted 4 lines · Zhiwei Zhang
The IBTA Software Transport Verbs specification requires the QP, Memory Window and Memory Region for a Bind Memory Window operation to belong to the same HCA and protection domain.
Quoted 8 lines
rxe only checked the QP and MW protection domain for type 2 MWs. Move the QP/MW PD check to the common bind path and also reject binding an MW to an MR from a different PD.
Invalid bind requests continue to fail with
IB_WC_MW_BIND_ERR.Reviewed-by Zhu Yanjun <[email protected]>Signed-off-by Zhiwei Zhang <[email protected]>
Thanks a lot. I am fine with this. Let us wait for the comments from Leon and Jason.
Zhu Yanjun
Quoted 45 lines
--- drivers/infiniband/sw/rxe/rxe_mw.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)drivers/infiniband/sw/rxe/rxe_mw.c +12
-8@@ -72,13 +72,6 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe,return -EINVAL ; } -/* C10-72 */ -if (unlikely (qp->pd !=to_rpd (mw->ibmw.pd))) { -rxe_dbg_mw (mw, -"attempt to bind type 2 MW with qp with different PD\n" ); -return -EINVAL ; - } -/* o10-37.2.40 */ if (unlikely (!mr || wqe->wr.wr.mw.length ==0 )) { rxe_dbg_mw(mw,@@ -87,10 +80,21 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, } } -/* remaining checks only apply to a nonzero MR */ +/* C10-72 */ +if (unlikely (qp->pd !=rxe_mw_pd (mw))) { +rxe_dbg_mw (mw,"attempt to bind MW with qp with different PD\n" ); +return -EINVAL ; + } +if (!mr)return 0 ; +/* remaining checks only apply to a nonzero MR */ +if (unlikely (qp->pd !=mr_pd (mr))) { +rxe_dbg_mw (mw,"attempt to bind MW/QP to MR with different PD\n" ); +return -EINVAL ; + } +if (unlikely (mr->access &IB_ZERO_BASED )) {rxe_dbg_mw (mw,"attempt to bind MW to zero based MR\n" );return -EINVAL ;
Signature · 2 lines
Best Regards, Yanjun.Zhu
Leon Romanovsky
AppliedQuoted 9 lines · Zhiwei Zhang
The IBTA Software Transport Verbs specification requires the QP, Memory Window and Memory Region for a Bind Memory Window operation to belong to the same HCA and protection domain.
rxe only checked the QP and MW protection domain for type 2 MWs. Move the QP/MW PD check to the common bind path and also reject binding an MW to an MR from a different PD.
[...]
Applied, thanks!
[1/1] RDMA/rxe: Check PDs for memory window binds
https://git.kernel.org/rdma/rdma/c/f58ea84a3584d1
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>