Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5096478pxb; Mon, 15 Feb 2021 09:21:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7GhM2ms32VShkMW69SOrQobeOPHpT9CkO7BsSRhUO3oH7aOnuWCcADQjnGqT3MkLUu/7r X-Received: by 2002:a17:906:4e0f:: with SMTP id z15mr1985913eju.199.1613409673182; Mon, 15 Feb 2021 09:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613409673; cv=none; d=google.com; s=arc-20160816; b=jtawNdnYCb9nJSuhTr9vy3yqKWkks0YrpHYJ+1rQ1uFhhfmjh7xsDzeETp9gYP0wsZ MxW7ey+JN89Waide1Bto2MtiwRVl3lw1aeQ0Iq+RnyTV4hoyjdhbWuQ1gZxqr7BXbhOO tXW0Goa2TVkvsUYxitCRP+lHajlxAbyanFQzlzzhERQTADz3+iuKbIHRQ+EQirUAb5Gp gSOSo6mw2ebBfqXi7jhqjPZ7G5nBl0sq3fdNjWKxugFViVJOB87A7V1CKwxl9EVcJNiz iV2ZTRI832ndYlKExtihwC8PLdYo44DV1nPUnk2Q/GoVOqiY3cI60w3hlIOzXQu36/0g B63A== 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=mMJbnS3m4KFKyi69i8MBKl8lmBZScMxD/r+nkK3uDKM=; b=cmvoQHzltobRzomFGtUb2ZJ9AgeNAcW8KwIXpWJrUhPndUhhGLTdQmmpegnBW44Fyb h0uP3ATClazzlS2KoRSjQNXnpmMPO6EJSt7aIoqdfb5S+i6n5RixcOdpV8OrJGoXzb3m ij1bBrFFbnepB2php8wF4GuXCF3DNSj3WEq5+K7M3L5agUod7mXgRvN1MmU7lrIcjxhv aiXfOSjJvAoEHQbWDm1W4o/KnUWouZ9YRGh7eeYKXcwuUNVBTBieOwkbZ/aaWRcic3tT +rGqG4tF7BN94nj9vTlnhl8bafELIQOrRqYX2S7ZnhQdq4YHgDbQiNlvV1MAg823B+eq 3bwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ED9eASDn; 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 i26si12949896edu.267.2021.02.15.09.20.49; Mon, 15 Feb 2021 09:21:13 -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=ED9eASDn; 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 S232665AbhBORUQ (ORCPT + 99 others); Mon, 15 Feb 2021 12:20:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:53262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbhBOPq7 (ORCPT ); Mon, 15 Feb 2021 10:46:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6CE9064EC0; Mon, 15 Feb 2021 15:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403324; bh=Hqraj+gjq6jLAt7EoKIIfleXiDxSneSE6qKy00InmPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ED9eASDnn1NTGcAckbbBCl+ADGsbNDiIqGQfmQBopBbWu/bVFwpsYdyCeLir/qd0m URkx/hCtyzke8I6mmP7MIQVoUMVtqsZYMelQWb+Sy7plMqDmTXm+M3Xp3JQakRneT+ +OCCz0Pkb7Dqwjx386AfW2glvBEBN0VjZkl7Huvo= 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 075/104] net: hns3: add a check for index in hclge_get_rss_key() Date: Mon, 15 Feb 2021 16:27:28 +0100 Message-Id: <20210215152721.874054509@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 532cfc0df1e4d68e74522ef4a0dcbf6ebbe68287 ] The index is received from vf, if use it directly, an out-of-bound issue may be caused, so add a check for this index before using it in hclge_get_rss_key(). Fixes: a638b1d8cc87 ("net: hns3: fix get VF RSS issue") Signed-off-by: Yufeng Mo Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index c997c90371550..9c8004fc9dc4f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -591,6 +591,17 @@ static void hclge_get_rss_key(struct hclge_vport *vport, index = mbx_req->msg.data[0]; + /* Check the query index of rss_hash_key from VF, make sure no + * more than the size of rss_hash_key. + */ + if (((index + 1) * HCLGE_RSS_MBX_RESP_LEN) > + sizeof(vport[0].rss_hash_key)) { + dev_warn(&hdev->pdev->dev, + "failed to get the rss hash key, the index(%u) invalid !\n", + index); + return; + } + memcpy(resp_msg->data, &hdev->vport[0].rss_hash_key[index * HCLGE_RSS_MBX_RESP_LEN], HCLGE_RSS_MBX_RESP_LEN); -- 2.27.0