Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1112277imm; Wed, 1 Aug 2018 10:22:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcI6CdyRkwwVAgBfPtDJX0SDK+FPU4WBYv76SyXOh3E69iTr/GXw4t4NFQ2s3CJyJflyuWO X-Received: by 2002:a17:902:1a9:: with SMTP id b38-v6mr25283738plb.89.1533144164774; Wed, 01 Aug 2018 10:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144164; cv=none; d=google.com; s=arc-20160816; b=T8XLyRn0isc4r5s7EuKsps/n773Ozjzhl9WV0oqD9nEP8CZdPY7/M3idH8Ak/DzsYq T6AghMw4SERK9Pb2VwR0gY/dF96N/ieAnPu5XNakhx9KlMydYR6hWgh0i1adlAvjis/d CKLgzj3XqKFhpeCadAN8dLpTjSpwZA9OkVf3/rSZKospod/PTE+yapVNcGtB+4WTR7Yi 7xAa0jCDaVpO/MZ6goer3+zwCwuWOCIz0eRHspzPziXJRXjID/pITFf3a07koYUxPkgj KrtJHfDaCcuZuVn1vqmKwIpo0FjVF/jEUcrnjp+YPjrUpBP2Ap63SF0YiXvYD8O2Hkav UYLA== 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=J+LWs2I9vX4BVOXoe6gurW+W01s73YV9iqD0UoqsCik=; b=JusZJ9fd5PJCpJRn2aPqNPVQ6O3QtjtUkaCPzxlLmrrGVYAH4+e+QddP5HKJ01HxFT ImkD6pgALHtmmKXlZRnGb33OjvicS7D19/QkHtUfC7EpKkYMQGCPtmsCI7MciY4en/3w bp8HlW384j1qouqkDQ2JQCGoQu7lOU9CPFOFdu3rM0nci3/MbvHwanU7QkA9Z/GYvDoe wQvxo9ieksNHnUrDO0c0xkKwgQ/y5pyb7VmdoIVsAqfoT7RT/qfI1IMwOvdvRD/JuNiD UKIymwmq6r1zNWFOG6KNx8pIiiCeWl9/BF/imQ2lmidgMvUbTLrCqbrfYLu3bO52Isp2 Z4Ng== 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 i20-v6si17204589pgb.547.2018.08.01.10.22.30; Wed, 01 Aug 2018 10:22:44 -0700 (PDT) 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 S2405472AbeHATHX (ORCPT + 99 others); Wed, 1 Aug 2018 15:07:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49184 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404995AbeHATHW (ORCPT ); Wed, 1 Aug 2018 15:07:22 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3CBE5CE6; Wed, 1 Aug 2018 17:20:41 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huazhong Tan , Peng Li , Salil Mehta , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 177/246] net: hns3: Fixes the out of bounds access in hclge_map_tqp Date: Wed, 1 Aug 2018 18:51:27 +0200 Message-Id: <20180801165020.193425274@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Huazhong Tan [ Upstream commit 38e62046d4c95272e2fb001d2d72baf48fa090e9 ] This patch fixes the handling of the check when number of vports are detected to be more than available TPQs. Current handling causes an out of bounds access in hclge_map_tqp(). Fixes: 7df7dad633e2 ("net: hns3: Refactor the mapping of tqp to vport") Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: Salil Mehta Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1272,8 +1272,11 @@ static int hclge_alloc_vport(struct hclg /* We need to alloc a vport for main NIC of PF */ num_vport = hdev->num_vmdq_vport + hdev->num_req_vfs + 1; - if (hdev->num_tqps < num_vport) - num_vport = hdev->num_tqps; + if (hdev->num_tqps < num_vport) { + dev_err(&hdev->pdev->dev, "tqps(%d) is less than vports(%d)", + hdev->num_tqps, num_vport); + return -EINVAL; + } /* Alloc the same number of TQPs for every vport */ tqp_per_vport = hdev->num_tqps / num_vport;