]> git.hungrycats.org Git - linux/commitdiff
RDMA/mana_ib: boundary check before installing cq callbacks
authorKonstantin Taranov <kotaranov@microsoft.com>
Fri, 26 Apr 2024 13:12:39 +0000 (06:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 May 2024 07:49:46 +0000 (09:49 +0200)
[ Upstream commit f79edef79b6a2161f4124112f9b0c46891bb0b74 ]

Add a boundary check inside mana_ib_install_cq_cb to prevent index overflow.

Fixes: 2a31c5a7e0d8 ("RDMA/mana_ib: Introduce mana_ib_install_cq_cb helper function")
Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
Link: https://lore.kernel.org/r/1714137160-5222-5-git-send-email-kotaranov@linux.microsoft.com
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/mana/cq.c

index c9129218f1be170cf91a59d4fe18b0689dc5ef80..89fcc09ded8a4d1fa5d613bc174d61c77ed19c4e 100644 (file)
@@ -81,6 +81,8 @@ int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq)
        struct gdma_context *gc = mdev_to_gc(mdev);
        struct gdma_queue *gdma_cq;
 
+       if (cq->queue.id >= gc->max_num_cqs)
+               return -EINVAL;
        /* Create CQ table entry */
        WARN_ON(gc->cq_table[cq->queue.id]);
        gdma_cq = kzalloc(sizeof(*gdma_cq), GFP_KERNEL);