Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6552001ybx; Mon, 11 Nov 2019 10:49:45 -0800 (PST) X-Google-Smtp-Source: APXvYqxfPxBLU8pX7j7+6IGByK3RFCYxmNklBGcG+EKvazIjEmdDObnRY6rB0flV+YFQvX/9qHIW X-Received: by 2002:a17:906:2654:: with SMTP id i20mr24226040ejc.163.1573498185407; Mon, 11 Nov 2019 10:49:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498185; cv=none; d=google.com; s=arc-20160816; b=VrSGAK1v2jgwQyTngxq4D3V8qkAmMZM9rhgwBYZ+/GZtWAXsAN65NNfyq946AgIdC2 3XvHjlw8yKj4Wry//+lnxqEpJJxms+7+hj61Hlb+y/OENK97bgEVpaicHdpYZNlo7xn7 MD9XQo/uj4HOa3MneL5K7sJItthsDoTWePOLVK5ItgzQ/7p8zXQWdXeaXyBVHPN0UKsW c6nSTRYJ1BAUQucbdxiPMpgop39evJg4GYq0gL9rtQcUFdeuqi2G4c1RiGIjViVs+1xw PGpR+71UtvpSXdYcYBykKkMSFDppm9GRqUu8Xk425yckt3VxGYL1r9CIlS20WC8BPSQI IseA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NyZDHF78RcnA7kF9V9j7gq+89R2lraxAf0oQPVYnNGA=; b=G9tlyeFPmanRhGGGW9u4sq8Rbsa3soQUvqWCmS5VfNbyZwpzo5FK3uodVxplgECsKs tVa5pWjDWPT+TwpI9/wrnZcmiX+NmPTffM0T24mvlSeL+Q7YdqlMIrjqPf1z8OyqQdSF UKQkdLd/mHdFvhGULwPmMh5HWDB244S7hJpxNS8+aJoHbOFiNMTbTRad3/BAj8u0LGGR hyY0urckwJYk0jTSVEsF/eCExfAVhVFX7Fz1hDey2vzQzRN5PgTe0IlHNCP/Q7xRjlld b3Fy1fW65d/Zw7QT8qBmngaS342O1oDFxY1kXiZsltJPs2OVPDwNtqbSY0SymZT9G9/z 62yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pmdsDwBV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e21si10169063ejt.77.2019.11.11.10.49.21; Mon, 11 Nov 2019 10:49:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pmdsDwBV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729935AbfKKSp7 (ORCPT + 99 others); Mon, 11 Nov 2019 13:45:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:38220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729528AbfKKSp5 (ORCPT ); Mon, 11 Nov 2019 13:45:57 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9597320674; Mon, 11 Nov 2019 18:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497957; bh=NJT/dnqZQQ5GqTsg0JsodvxiF/DmvijiBBevYIJ0iqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pmdsDwBVHvoG8Mp7bGIVdDwP+1jz9L4OlE8n02EReY3aOHr4AiYow19DfkoAfuq4a 95gt1Iiq/XhEeP4409PHPDrceWH9GEphD5l5lJqgHAgBBnHaIPCTHtLFnPqlxRngWw Yv2++lCvZGws8Lbv0NqRcVeSqxA4XhNqwQ2HovOU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.19 080/125] RDMA/uverbs: Prevent potential underflow Date: Mon, 11 Nov 2019 19:28:39 +0100 Message-Id: <20191111181450.802298592@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ 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 Reviewed-by: Jason Gunthorpe Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/uverbs.h | 2 +- include/rdma/ib_verbs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 5df8e548cc146..4a14de2d8c716 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; struct ib_device __rcu *ib_dev; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index b7d63c3970d18..f3d475024d376 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -310,7 +310,7 @@ struct ib_tm_caps { struct ib_cq_init_attr { unsigned int cqe; - int comp_vector; + u32 comp_vector; u32 flags; }; -- 2.20.1