Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10423573ybi; Wed, 24 Jul 2019 22:58:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRhgIv6uspPn9yr13ym9qmVOBJHMHnelvnQdBHowbEVeZzgjk77GNe+2Zo0ox19U8u8sQt X-Received: by 2002:a65:6259:: with SMTP id q25mr45084584pgv.145.1564034319541; Wed, 24 Jul 2019 22:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034319; cv=none; d=google.com; s=arc-20160816; b=c4626zFdb8tvsL8Yjglc2+GB77n/ap6HhRhu/QnCsMcfEjnI0TSMd+GFsAcS730yVy HeWqxjQ5o4dPEcLlxMrDi2ahNtOzQc+PkTB351oIm29BJcMeWKL4sg89hFWcDQpYp/tc aIij342tTaEFs/Ae0fTmOwyLu7gbw5irWZmP8ACzrDbEHcTyNHiGv1a3QTHMNHobuNJ8 4kBDuCb6xvqlq1MJLLYRCRXpgCkUtCXQMJz7OyrPa4pwiKFyOhDvC2P0r0rwl2nFBKYH KmUvbp6giTTIL9uJzcKUaMJa0UlSNzn4o6odG7PifU/ijbB8iCPM3MfesAx/SPr2BQmZ 2EGA== 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=LxZCnUQBP5yiOC4MXz86FicVALravLHBYUJ8200dDi8=; b=zlHctcAKArfPV4zNwYYxxrGhZ2SN++snIMPJnL5XoKCxfFvRWStKAwOzR0wzQv9zvP aOUBVYiuJGm4NWz1Eq9Z7L5ywRhgKSjEuhI/OZylvVvEEdJRxzlOgyLJ3QlQcN4D7rKL yDjUE8GyNXiRL32ceY69wHNfrLvIdatqTNqNBzwQ3heoO9HzkNGOuzDXFm8gANQd6ssi GAkeB+9IFuRaK+EO3P33ZiTnTY0MXXtQXX53xvrGZOKDSF5F3KM54QE19T1aCSJ4Vfxu It8V59miNtiU8QbuiSVK0VkQDGO4irIfdLL2hECvQY5LFArpfimRMbwO1ZicNigZGjZc GBFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GO7tqOHl; 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 e1si7850732pge.227.2019.07.24.22.58.25; Wed, 24 Jul 2019 22:58:39 -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=GO7tqOHl; 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 S2390797AbfGYFmQ (ORCPT + 99 others); Thu, 25 Jul 2019 01:42:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:57148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404830AbfGYFmO (ORCPT ); Thu, 25 Jul 2019 01:42:14 -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 89CBC21880; Thu, 25 Jul 2019 05:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033334; bh=37X1Wmkz2niaasL0mxqxDwuAND03i84ksVWBL6nOflA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GO7tqOHlf5VovJxQ170mg0ZZUFYQ0Nm3kTIEyeeVYt8f3oVhKkKfNsUpvRerfOTqe M9rV2poTCPhtbc24wT7moH9BT/0hlWWlG20d/MwBK/isAESK5cqm+N4ZkFNALQlvIo tRy4vaEBbiiB7CHnB2shxJfO3wz8ay3Xj97Z93CE= 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.19 130/271] net: hns3: add some error checking in hclge_tm module Date: Wed, 24 Jul 2019 21:19:59 +0200 Message-Id: <20190724191706.375089488@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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 48235dc2dd56..11e9259ca040 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -54,7 +54,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]; @@ -1057,6 +1058,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