Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3785126ybi; Mon, 29 Jul 2019 12:34:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiyRed4J70tlmUmquUX16QeHqzPqGfaXCjAE9zNddq9Pw5+KJUR3e7qBvPVb3k+AqMyd5w X-Received: by 2002:a17:902:d90a:: with SMTP id c10mr109032676plz.208.1564428869119; Mon, 29 Jul 2019 12:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428869; cv=none; d=google.com; s=arc-20160816; b=gCgw+IHQab711xEyjnWQNg532TFNsHhu/0/bnfDHUu+dAJ+zvhNd6sPjSYjVmjWBaX Zkz+PiKUvGHN93DXH0pQr70q6xV98Lh3TMDHNAxIpfVMc3eTA9elvhFGsa8B0BDk13TR OiofCo2cZF5i26jtpkNBQkouzAKnbjuK/U+0Ae93JO/mmT8abf9l4Lb9VI7UssbQcHTM kqtOaDHIleEfjVBSVmBb7VVe/0jyG7Ykd68OqvavxJb/TZ85mdLak2TWkAxotj9PNQYT 7rkSZBunyF4jU1Yop1Qy5WycjCu1XsYwohnyiyWm7StivOpOGNYGfPnUAfIL04G7msua khWw== 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=Urd7GVVIYQapx9rr91RE60CVwRje4j6GpiWPXi8uUY4=; b=WpPtPv3sWh2UtNxCQBeLjNuDu1e4VTy+KhxpTLrBiabC3qCiaw5nUIEKgst5s5KWfO sGskAIvzJeRz47+YqtZgKRTo3V9DCS93aK2usogczlXZEG4FzZdWmhzY8etjKbrfDQIQ muXtp4bG+krUlY6/2cnDarwQpzwiaENeUogT3qJQXPmrByM+bL4GfzuHXfEu7934G6Hw Z/lXWKGyt/rj/PoUTY9ZCKVUwSVmkcurfe0v6DtgNBhRkGpWfzZiioYYGk2YARdTns/V axoXl7xQTeeUGvBll//KKONSHo2c/eYB10tYqyLNk8ohWkeJ6449GS9RWqsMZWS6VE2v Y8uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mgrg8gl0; 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 l67si27215224plb.370.2019.07.29.12.34.14; Mon, 29 Jul 2019 12:34:29 -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; dkim=pass header.i=@kernel.org header.s=default header.b=mgrg8gl0; 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 S1729979AbfG2T2I (ORCPT + 99 others); Mon, 29 Jul 2019 15:28:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:40794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727628AbfG2T2G (ORCPT ); Mon, 29 Jul 2019 15:28:06 -0400 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 CE79C217D4; Mon, 29 Jul 2019 19:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428485; bh=juKBMjz2oE2R3XxbmMl1+0utoP+sfYheUsaNQ6FnA0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mgrg8gl0rjT1+1C8dkx5vh6Z/5YPpAcf6oQZjtjWzHyV4IzqZE7YDzCVCtUlOi+jg kI85l0/GEya3oFcNIgoyPjVv3hPyuJt1iHXGfLnxEfX0JDSwLK4OqgX1dgtn6e4rNW YDZLigkVYjzwtnvYlkBGGCoIOHo47blS4UREYRis= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunsheng Lin , Peng Li , Huazhong Tan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 090/293] net: hns3: add some error checking in hclge_tm module Date: Mon, 29 Jul 2019 21:19:41 +0200 Message-Id: <20190729190831.491798276@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 [ Upstream commit 04f25edb48c441fc278ecc154c270f16966cbb90 ] When hdev->tx_sch_mode is HCLGE_FLAG_VNET_BASE_SCH_MODE, the hclge_tm_schd_mode_vnet_base_cfg calls hclge_tm_pri_schd_mode_cfg with vport->vport_id as pri_id, which is used as index for hdev->tm_info.tc_info, it will cause out of bound access issue if vport_id is equal to or larger than HNAE3_MAX_TC. Also hardware only support maximum speed of HCLGE_ETHER_MAX_RATE. So this patch adds two checks for above cases. Fixes: 848440544b41 ("net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index 73a75d7cc551..55228b91d80b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -57,7 +57,8 @@ static int hclge_shaper_para_calc(u32 ir, u8 shaper_level, u32 tick; /* Calc tick */ - if (shaper_level >= HCLGE_SHAPER_LVL_CNT) + if (shaper_level >= HCLGE_SHAPER_LVL_CNT || + ir > HCLGE_ETHER_MAX_RATE) return -EINVAL; tick = tick_array[shaper_level]; @@ -893,6 +894,9 @@ static int hclge_tm_schd_mode_vnet_base_cfg(struct hclge_vport *vport) int ret; u8 i; + if (vport->vport_id >= HNAE3_MAX_TC) + return -EINVAL; + ret = hclge_tm_pri_schd_mode_cfg(hdev, vport->vport_id); if (ret) return ret; -- 2.20.1