]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
RDMA/uverbs: Prevent potential underflow
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 11 Oct 2019 13:34:19 +0000 (16:34 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:16:12 +0000 (13:16 +0100)
commit4042a5d05e9731242ef82eec9ea99f71e7bce494
tree913f3499b6647ab90a0b250b665d4d01c96b90a1
parent725ec645a8432cf684a4db0519c35bb1c2ad5d07
RDMA/uverbs: Prevent potential underflow

BugLink: https://bugs.launchpad.net/bugs/1853519
[ Upstream commit a9018adfde809d44e71189b984fa61cc89682b5e ]

The issue is in drivers/infiniband/core/uverbs_std_types_cq.c in the
UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE) function.  We check that:

        if (attr.comp_vector >= attrs->ufile->device->num_comp_vectors) {

But we don't check if "attr.comp_vector" is negative.  It could
potentially lead to an array underflow.  My concern would be where
cq->vector is used in the create_cq() function from the cxgb4 driver.

And really "attr.comp_vector" is appears as a u32 to user space so that's
the right type to use.

Fixes: 9ee79fce3642 ("IB/core: Add completion queue (cq) object actions")
Link: https://lore.kernel.org/r/20191011133419.GA22905@mwanda
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/infiniband/core/uverbs.h
include/rdma/ib_verbs.h