Received: by 10.223.185.116 with SMTP id b49csp8918401wrg; Fri, 2 Mar 2018 10:07:35 -0800 (PST) X-Google-Smtp-Source: AG47ELvv5pp9CWDfbgk10HuYrdCm6mOh+yyUgYeGYDDzY6KJV0OdkffNFcTda7/sKJuBOtvgGdnS X-Received: by 2002:a17:902:aa81:: with SMTP id d1-v6mr6005658plr.251.1520014055403; Fri, 02 Mar 2018 10:07:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520014055; cv=none; d=google.com; s=arc-20160816; b=Y/pMTsrai1sEvh60ibNZ8zJzER/RtkTXHaO9ZCP486BwY8wCeKdp9eMERbC1DyosaP c+DqDJ11wrniYsqa5yY9Ev8RsYivm8IqMV+1ND++TUfv3f/jVZWRdAi9zMFnGY3p5cc4 RUgskEYv+my4OSeW20j1VnLJH7kchLTM3IRv61jGs5uMQknoLMna+P2bL1iHbOiVnci0 aip5kavQl6VZX2O6o3/sW84c2NBbAGuSqRMtgxKKDSronUE7zmbQfEIUpa7H1/J3/yxu TZpUt75r1Pq571fPa/zewUcSnbxWOrvpI3Jb6zXcYRrQAORCsg+WovmlKkt7mVQYgelD 1GTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=6Erz9jp8Xvv7sVt0b2C7ahaVJNLHpyILg1SxgqvjxZA=; b=VvqXhQR64ypyYoRl5nHwZWmGudpfUj9NfPol4ZlXfsgkWOGaUn/QgkvJPJdgxlXMRX Yq5OMYiQi/p/q2a2rs5SQpiQ+dHfH6GfJrEEoW0nvqg/yVsjRAxaMnV+3tQZ7/QAZIEK L6wC5htI3k3lx4AtiK9EqXfqSuz+cnlpir+ZhBwTDXok3xnPmx7ecCQ0ZOvCETRAt1Eo biX1ws8bi9Ui9Bb3uA+YXHFkH7SxUUtBGjHzJ3rJYJBhMZyvWJFHwc7PVg7LshPo/v8i 8E6oyJwy2YMKHph0PG6JBYgrglOLazdoF1mn4yfeAum+p4HYfEQcWWIl+9ntma2Zj10u m1Hw== ARC-Authentication-Results: i=1; mx.google.com; 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 h3-v6si5125709pll.831.2018.03.02.10.07.20; Fri, 02 Mar 2018 10:07:35 -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; 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 S1426907AbeCBLGt (ORCPT + 99 others); Fri, 2 Mar 2018 06:06:49 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50656 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423583AbeCBIzB (ORCPT ); Fri, 2 Mar 2018 03:55:01 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9B8D7121E; Fri, 2 Mar 2018 08:55:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Venkat Devvuru , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 26/34] bnxt_en: Fix the Invalid VF id check in bnxt_vf_ndo_prep routine. Date: Fri, 2 Mar 2018 09:51:22 +0100 Message-Id: <20180302084437.693698886@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180302084435.842679610@linuxfoundation.org> References: <20180302084435.842679610@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Venkat Duvvuru [ Upstream commit 78f300049335ae81a5cc6b4b232481dc5e1f9d41 ] In bnxt_vf_ndo_prep (which is called by bnxt_get_vf_config ndo), there is a check for "Invalid VF id". Currently, the check is done against max_vfs. However, the user doesn't always create max_vfs. So, the check should be against the created number of VFs. The number of bnxt_vf_info structures that are allocated in bnxt_alloc_vf_resources routine is the "number of requested VFs". So, if an "invalid VF id" falls between the requested number of VFs and the max_vfs, the driver will be dereferencing an invalid pointer. Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Signed-off-by: Venkat Devvuru Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c @@ -29,7 +29,7 @@ static int bnxt_vf_ndo_prep(struct bnxt netdev_err(bp->dev, "vf ndo called though sriov is disabled\n"); return -EINVAL; } - if (vf_id >= bp->pf.max_vfs) { + if (vf_id >= bp->pf.active_vfs) { netdev_err(bp->dev, "Invalid VF id %d\n", vf_id); return -EINVAL; }