Skip to content

Commit 887bfe5

Browse files
Konstantin Taranovjgunthorpe
authored andcommitted
RDMA/mana_ib: check cqe length for kernel CQs
Check queue size during kernel CQ creation to prevent overflow of u32. Fixes: bec127e ("RDMA/mana_ib: create kernel-level CQs") Link: https://patch.msgid.link/r/[email protected] Signed-off-by: Konstantin Taranov <[email protected]> Reviewed-by: Long Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent d95e99a commit 887bfe5

File tree

1 file changed

+4
-0
lines changed
  • drivers/infiniband/hw/mana

1 file changed

+4
-0
lines changed

drivers/infiniband/hw/mana/cq.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
5656
doorbell = mana_ucontext->doorbell;
5757
} else {
5858
is_rnic_cq = true;
59+
if (attr->cqe > U32_MAX / COMP_ENTRY_SIZE / 2 + 1) {
60+
ibdev_dbg(ibdev, "CQE %d exceeding limit\n", attr->cqe);
61+
return -EINVAL;
62+
}
5963
buf_size = MANA_PAGE_ALIGN(roundup_pow_of_two(attr->cqe * COMP_ENTRY_SIZE));
6064
cq->cqe = buf_size / COMP_ENTRY_SIZE;
6165
err = mana_ib_create_kernel_queue(mdev, buf_size, GDMA_CQ, &cq->queue);

0 commit comments

Comments
 (0)