Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/mana_ib: check cqe length for kernel CQs

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

Fixes: bec127e45d9f ("RDMA/mana_ib: create kernel-level CQs")
Link: https://patch.msgid.link/r/1761213780-5457-1-git-send-email-kotaranov@linux.microsoft.com
Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Konstantin Taranov and committed by
Jason Gunthorpe
887bfe59 d95e99a7

+4
+4
drivers/infiniband/hw/mana/cq.c
··· 56 56 doorbell = mana_ucontext->doorbell; 57 57 } else { 58 58 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 + } 59 63 buf_size = MANA_PAGE_ALIGN(roundup_pow_of_two(attr->cqe * COMP_ENTRY_SIZE)); 60 64 cq->cqe = buf_size / COMP_ENTRY_SIZE; 61 65 err = mana_ib_create_kernel_queue(mdev, buf_size, GDMA_CQ, &cq->queue);