Skip to contentSkip to conversation

RDMA/irdma: Do not allow rereg_mr to revive defunct MRs

PATCH Applied Jacob Moroni 2 participants 2 messages Oct 29 – Nov 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 5ac388db27c4 ("RDMA/irdma: Add support to re-register a memory region")
---
 drivers/infiniband/hw/irdma/verbs.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +3 -0
index c91c55917de9..fd1b1454f026 100644
@@ -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
#1 lore raw
Quoted 9 lines · Jacob Moroni

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.

[...]

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]>