Skip to contentSkip to conversation

RDMA/mana_ib: check cqe length for kernel CQs

PATCH Applied Konstantin Taranov 3 participants 3 messages Oct 23, 2025 – Dec 17, 2025

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

PATCH 1/1 RDMA/mana_ib: check cqe length for kernel CQs

From: Konstantin Taranov <[email protected]>

Check queue size during kernel CQ creation to prevent overflow of u32.

Fixes bec127e45d9f ("RDMA/mana_ib: create kernel-level CQs")
---
 drivers/infiniband/hw/mana/cq.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/infiniband/hw/mana/cq.c +4 -0
index 1becc8779..7600412b0 100644
@@ -56,6 +56,10 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 		doorbell = mana_ucontext->doorbell;
 	} else {
 		is_rnic_cq = true;
+		if (attr->cqe > U32_MAX / COMP_ENTRY_SIZE / 2 + 1) {
+			ibdev_dbg(ibdev, "CQE %d exceeding limit\n", attr->cqe);
+			return -EINVAL;
+		}
 		buf_size = MANA_PAGE_ALIGN(roundup_pow_of_two(attr->cqe * COMP_ENTRY_SIZE));
 		cq->cqe = buf_size / COMP_ENTRY_SIZE;
 		err = mana_ib_create_kernel_queue(mdev, buf_size, GDMA_CQ, &cq->queue);
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines

Subject: [PATCH rdma-next] RDMA/mana_ib: check cqe length for kernel CQs

From: Konstantin Taranov <[email protected]>

Check queue size during kernel CQ creation to prevent overflow of u32.

Fixes bec127e45d9f ("RDMA/mana_ib: create kernel-level CQs")
Quoted 25 lines
---
 drivers/infiniband/hw/mana/cq.c | 4 ++++
 1 file changed, 4 insertions(+)
(quoted diff) +0 -0

b/drivers/infiniband/hw/mana/cq.c index 1becc8779..7600412b0 100644

drivers/infiniband/hw/mana/cq.c +4 -0
@@ -56,6 +56,10 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct
 ib_cq_init_attr *attr,
 		doorbell = mana_ucontext->doorbell;
 	} else {
 		is_rnic_cq = true;
+		if (attr->cqe > U32_MAX / COMP_ENTRY_SIZE / 2 + 1) {
+			ibdev_dbg(ibdev, "CQE %d exceeding limit\n", attr-
 >cqe);
+			return -EINVAL;
+		}
 		buf_size = MANA_PAGE_ALIGN(roundup_pow_of_two(attr-
Quoted 1 line

cqe * COMP_ENTRY_SIZE));

drivers/infiniband/hw/mana/cq.c +0 -0
 		cq->cqe = buf_size / COMP_ENTRY_SIZE;
 		err = mana_ib_create_kernel_queue(mdev, buf_size,

GDMA_CQ, &cq->queue);
--
2.43.0

maintainer Applied
#2 lore raw
In reply to Konstantin Taranov
Quoted 10 lines · Konstantin Taranov

From: Konstantin Taranov <[email protected]>

Check queue size during kernel CQ creation to prevent overflow of u32.

Fixes bec127e45d9f ("RDMA/mana_ib: create kernel-level CQs")
---
 drivers/infiniband/hw/mana/cq.c | 4 ++++
 1 file changed, 4 insertions(+)

Applied to for-rc, thanks

Jason