Skip to contentSkip to conversation

RDMA/irdma: Prevent rereg_mr for non-mem regions

PATCH Superseded Jacob Moroni 2 participants 2 messages Jun 17

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/irdma: Prevent rereg_mr for non-mem regions

When a QP/CQ/SRQ is created, a two step process is used where the buffer is allocated in userspace and explicitly registered with the normal reg_mr mechanism prior to creating the actual QP/CQ/SRQ object.

These special registrations are indicated via an ABI field so the driver knows that they do not have a valid mkey and to skip the actual CQP command submission.

Since these are real MRs objects from the core's perspective, it is possible for a user application to invoke rereg_mr on them and cause a real CQP op to be emitted with the zero-initialized mkey value of 0.

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 b79f5afe68..da8b4ae786 100644
@@ -3791,6 +3791,9 @@ static struct ib_mr *irdma_rereg_user_mr(struct ib_mr *ib_mr, int flags,
 	if (flags & ~(IB_MR_REREG_TRANS | IB_MR_REREG_PD | IB_MR_REREG_ACCESS))
 		return ERR_PTR(-EOPNOTSUPP);
 
+	if (iwmr->type != IRDMA_MEMREG_TYPE_MEM)
+		return ERR_PTR(-EINVAL);
+
 	if (dmabuf_revocable) {
 		umem_dmabuf = to_ib_umem_dmabuf(iwmr->region);
 
Signature · 1 line
2.54.0.1189.g8c84645362-goog
Reviewed-by on v1 1/1
#1 lore raw

drivers/infiniband/hw/irdma/verbs.c static struct ib_mr *irdma_rereg_user_mr(struct ib_mr *ib_mr, int flags, · line 3798

Quoted 13 lines · Jacob Moroni
drivers/infiniband/hw/irdma/verbs.c +3 -0
index b79f5afe68..da8b4ae786 100644
@@ -3791,6 +3791,9 @@ static struct ib_mr *irdma_rereg_user_mr(struct ib_mr *ib_mr, int flags,
        if (flags & ~(IB_MR_REREG_TRANS | IB_MR_REREG_PD | IB_MR_REREG_ACCESS))
                return ERR_PTR(-EOPNOTSUPP);
 
+       if (iwmr->type != IRDMA_MEMREG_TYPE_MEM)
+               return ERR_PTR(-EINVAL);
+
        if (dmabuf_revocable) {
                umem_dmabuf = to_ib_umem_dmabuf(iwmr->region);

This looks like a good catch for an issue specific to irdma's handling of queue buffers.