linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] uverbs: prevent potential underflow
@ 2019-10-05  5:23 Dan Carpenter
  2019-10-08 19:44 ` Jason Gunthorpe
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-10-05  5:23 UTC (permalink / raw)
  To: Doug Ledford, Potnuri Bharat Teja, Matan Barak
  Cc: Jason Gunthorpe, Leon Romanovsky, Shamir Rabinovitch,
	Matthew Wilcox, Michael Guralnik, linux-rdma, linux-kernel,
	kernel-janitors

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 that "attr.comp_vector" whether 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.

Fixes: 9ee79fce3642 ("IB/core: Add completion queue (cq) object actions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/infiniband/core/uverbs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 1e5aeb39f774..63f7f7db5902 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -98,7 +98,7 @@ ib_uverbs_init_udata_buf_or_null(struct ib_udata *udata,
 
 struct ib_uverbs_device {
 	atomic_t				refcount;
-	int					num_comp_vectors;
+	u32					num_comp_vectors;
 	struct completion			comp;
 	struct device				dev;
 	/* First group for device attributes, NULL terminated array */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-22 18:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-05  5:23 [PATCH] uverbs: prevent potential underflow Dan Carpenter
2019-10-08 19:44 ` Jason Gunthorpe
2019-10-09  7:35   ` Dan Carpenter
2019-10-11 13:34   ` [PATCH v2] " Dan Carpenter
2019-10-22 18:15     ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).