summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYufeng Mo <moyufeng@huawei.com>2021-02-09 17:03:07 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-02-17 11:02:27 +0100
commit5ff69431b7633b1cfe30ceff58c6843aa7cb4d46 (patch)
tree1f4d0d5a3a81f2a774a8c6c863162acaab13a971
parent2c0e46258eab60dfa447d0ab7e316478f0f852a3 (diff)
downloadlinux-stable-5ff69431b7633b1cfe30ceff58c6843aa7cb4d46.tar.gz
linux-stable-5ff69431b7633b1cfe30ceff58c6843aa7cb4d46.tar.bz2
linux-stable-5ff69431b7633b1cfe30ceff58c6843aa7cb4d46.zip
net: hns3: add a check for index in hclge_get_rss_key()
[ 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 <moyufeng@huawei.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
index c997c9037155..9c8004fc9dc4 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);