RDMA/irdma: Do not allow rereg_mr to revive defunct MRs
Subsystems (2)
PATCH 2/3 RDMA/irdma: Do not allow rereg_mr to revive defunct MRs
An MR can become "defunct" if a previous rereg_mr happened to fail in between deregistering the old MR in HW and reregistering it (e.g., due to ib_umem_get_va() failing in the IB_MR_REREG_TRANS case).
In this case, the MR is left in a state where the umem may have already been released.
If rereg_mr then runs again, but without IB_MR_REREG_TRANS, it will end up reregistering the MR with stale translation info.
Fix this by rejecting any attempt to reregister an MR that has previously failed during rereg_mr after the point where the MR has been deregistered in HW.
--- drivers/infiniband/hw/irdma/verbs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +3 -0
@@ -3873,6 +3873,9 @@ static struct ib_mr *irdma_rereg_user_mr(struct ib_mr *ib_mr, int flags,if (ret)return ERR_PTR (ret); +if (!iwmr->is_hwreg) +return ERR_PTR (-EINVAL ); + ret =irdma_hwdereg_mr (ib_mr);if (ret)return ERR_PTR (ret);
Signature · 1 line
2.56.0.313.g2479322e68-goog
Leon Romanovsky
AppliedQuoted 9 lines · Jacob Moroni
An MR can become "defunct" if a previous
rereg_mrhappened to fail in between deregistering the old MR in HW and reregistering it (e.g., due toib_umem_get_va()failing in theIB_MR_REREG_TRANScase).In this case, the MR is left in a state where the umem may have already been released.
[...]
Applied, thanks!
[2/3] RDMA/irdma: Do not allow rereg_mr to revive defunct MRs
https://git.kernel.org/rdma/rdma/c/6b5c8236e3008f
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>