Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5070587pxb; Mon, 15 Feb 2021 08:44:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCkVVCSDzJlKTwj2N9OPfjRHzCy6HainMOwtA1N2qJhJuB5pPCDeW3ZVp3+qeZgyzUKpoY X-Received: by 2002:a17:906:2bc2:: with SMTP id n2mr15978673ejg.381.1613407465576; Mon, 15 Feb 2021 08:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613407465; cv=none; d=google.com; s=arc-20160816; b=gWGwPsZfGaEEVSpME50HCt5ltbn1zI9iDuPn86+PhMNNruFJHXDLwske00lJF1tW/X 8AjKQ5qrugWAt/NIqELDs0agIfUUwMMSu7RBscrvYP4wFrpvAUSqHAGG8YOz2KvzBPCO 0pKE3TTHUrIpBAU85/ISuIR2EKmibZLR8b8M30iXYbHewAGp5LWUl9PWCPXi049+E1EI u0aInCBppzgYKhRIlqx4lNVyoGrkpKHpPUyW818gKEVSNjDHxaGtpcrdWWO29lhqPeWl Kvx3xhCv3T0h2ipSxgZC62fkllIDTOw41EUyfIlLrIKX843mGS8dHDM2PIXNZpaIxHnY VaIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/K24Uj6MZBcmTYa4WtqRF/bFOB44dF81B1gn/LotCgM=; b=AY2pW/Yp7dgdP3uqXHXpoMhSsa9G9YHmCYXAdjy6tivP6E3oDYCuiU1bSwl0mEGSsQ WRxXyQcgGFHASvCzAzNcAEhab9gZsMVasmMf6YQjMkm2rfKNYT8zCwOHOQuY8YVEXGdZ kFsTD62JfoXctGxKpFFPNWrd5JmhNRGsML4Nr4R4a01dhvLpAw9VR6JAYcsLRRcQL7/v mEoB0ULmGXQEas/0JwoBQP7UdfXfGbz790668IGBQI2stvu143K6ZIpYb0pKdN7WKvs0 FRdOs8F0L3d7w92QJ+73YBAkjiBZFp9Zzzw0iM0/ROa3D+h4sDxY0AmkHH0CO2R6VdHi E7Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O3E17FKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si12436570ejy.191.2021.02.15.08.44.02; Mon, 15 Feb 2021 08:44:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O3E17FKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231397AbhBOQlN (ORCPT + 99 others); Mon, 15 Feb 2021 11:41:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:50042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231557AbhBOPiA (ORCPT ); Mon, 15 Feb 2021 10:38:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 361D164EB1; Mon, 15 Feb 2021 15:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403225; bh=2hljRmYRsaCubJA6yh5FcPHKxO/+/e/4mzZZ0NUXBqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3E17FKS5MHYwsRqFofuwvNASKQTVTcnrx1eyLHXPKO8hkGHtA2fT5JBWh2gK3QHt aDl5aounkbBC79ZLGgcwhS/wWeVR5b5AM/rfmiFSlmag02lGonvFS94vxh24B6yrK+ wwwlCQlzAU4lIaFcp9+0J4ZQwlOCvuaUU/JHBmsM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yufeng Mo , Huazhong Tan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 074/104] net: hns3: add a check for tqp_index in hclge_get_ring_chain_from_mbx() Date: Mon, 15 Feb 2021 16:27:27 +0100 Message-Id: <20210215152721.840893688@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152719.459796636@linuxfoundation.org> References: <20210215152719.459796636@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yufeng Mo [ Upstream commit 326334aad024a60f46dc5e7dbe1efe32da3ca66f ] The tqp_index is received from vf, if use it directly, an out-of-bound issue may be caused, so add a check for this tqp_index before using it in hclge_get_ring_chain_from_mbx(). Fixes: 84e095d64ed9 ("net: hns3: Change PF to add ring-vect binding & resetQ to mailbox") Signed-off-by: Yufeng Mo Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 3ab6db2588d31..c997c90371550 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -158,21 +158,31 @@ static int hclge_get_ring_chain_from_mbx( struct hclge_vport *vport) { struct hnae3_ring_chain_node *cur_chain, *new_chain; + struct hclge_dev *hdev = vport->back; int ring_num; - int i = 0; + int i; ring_num = req->msg.ring_num; if (ring_num > HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM) return -ENOMEM; + for (i = 0; i < ring_num; i++) { + if (req->msg.param[i].tqp_index >= vport->nic.kinfo.rss_size) { + dev_err(&hdev->pdev->dev, "tqp index(%u) is out of range(0-%u)\n", + req->msg.param[i].tqp_index, + vport->nic.kinfo.rss_size - 1); + return -EINVAL; + } + } + hnae3_set_bit(ring_chain->flag, HNAE3_RING_TYPE_B, - req->msg.param[i].ring_type); + req->msg.param[0].ring_type); ring_chain->tqp_index = hclge_get_queue_id(vport->nic.kinfo.tqp - [req->msg.param[i].tqp_index]); + [req->msg.param[0].tqp_index]); hnae3_set_field(ring_chain->int_gl_idx, HNAE3_RING_GL_IDX_M, - HNAE3_RING_GL_IDX_S, req->msg.param[i].int_gl_index); + HNAE3_RING_GL_IDX_S, req->msg.param[0].int_gl_index); cur_chain = ring_chain; -- 2.27.0