Skip to content

Commit

Permalink
net: hns3: add a check for index in hclge_get_rss_key()
Browse files Browse the repository at this point in the history
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: a638b1d ("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>
  • Loading branch information
Yufeng Mo authored and davem330 committed Feb 9, 2021
1 parent 326334a commit 532cfc0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
Expand Up @@ -607,6 +607,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);
Expand Down

0 comments on commit 532cfc0

Please sign in to comment.