Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9932791ybi; Wed, 24 Jul 2019 12:34:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyX/MNqTcHt7Rz9zh0wVoJYv277M+XNHkNfFZy4ygI7guqwdAqwZxYv1qpAD0x+JFgulddw X-Received: by 2002:a63:5c07:: with SMTP id q7mr30752117pgb.436.1563996871523; Wed, 24 Jul 2019 12:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996871; cv=none; d=google.com; s=arc-20160816; b=uI87U6utuL7C/+olMwQ8vqGO8VvOrzRzi4nXF0YKkrx1+vDSSbg0lEwFv1oB/PLOE7 4sTcjMih5p1pLjcDDP5wWP1dyQXLGLk0gv2GdCbdkcPMQvubnH1G6yeqpOHWh9WRh3FX v0FSocXNenOaz4v8jWCPa8NUV2tT7X+ClO217GpjmuhtCx4ScKVNe44EMch5/pq1YrwB 2M6frQ9CNahCWlUwqPChemxw72Mh30snAqUYSYShPOWhE49AQYboEm29qTQTtAOBzkLM JZHHc2V1qNX8ToCktigobTxmYnjgPyDWkgiygVLk0+thhhRz4ih9tLxMlJrWniRk7VGH se2g== 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=N/OZOJrQuM6EwXvwk5kteaLZ5byw4idUn9aXi0wqRrU=; b=SHVu04CG8OCd/KxzZcUnp8CC/1pOgjrwpUPTBOeH30ZYEF++6NhmRRwzYQtkCromBz ouovDOVgQCQbJydS7zgwExkma6Kb5dyz9bkVvBMd7NWBt1pTdBP0Bw6lwGJsZOYz0NTY +lhFwzG6aZgMcCnETCjBy36beOh8VHyQJq9A9zU+8gZ0rNiZn+QWqVWhhFWLV5K2rsN3 S2Ar0iHDOrIiyzroOdpxhJLKhyPuUX50Yos4la+rRmR9brkjlV0G9/zPUB8kaYU6R8Kd 4lTnmy5CmoaCFS40DV1fcXGqn4BOrPmxR9OdzwTOVcUSIyZoQVOslvTn0MhVC4kRtgNf CoCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cf0KWSEc; 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 e14si17995410pfl.261.2019.07.24.12.34.16; Wed, 24 Jul 2019 12:34:31 -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=cf0KWSEc; 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 S2388604AbfGXTcJ (ORCPT + 99 others); Wed, 24 Jul 2019 15:32:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:53354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388589AbfGXTcF (ORCPT ); Wed, 24 Jul 2019 15:32:05 -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 470B2229F4; Wed, 24 Jul 2019 19:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996724; bh=Y1nqmQ4xUMzB9/IdK+W47PHTspZupZm48fazF7jivv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cf0KWSEc8cJ6eOlqkelCWP3y2txph3bxAWWHc7OYh1PDgUFu0Y94wtT2Np+YAVl7G R04l3p1gEw55YgESDd4wHuDqxUkGf1endqC16YcicmjLwp5pNrSm1IdrxVNSBkC3Mo 854dBCR7ClgrNQRYKTaPNM9A578Px0H7XFgwOgCk= 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 5.2 194/413] net: hns3: add some error checking in hclge_tm module Date: Wed, 24 Jul 2019 21:18:05 +0200 Message-Id: <20190724191748.504421576@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 a7bbb6d3091a..0d53062f7bb5 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]; @@ -1124,6 +1125,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