net: hns3: add checking for vf id of mailbox

[ Upstream commit 4e2969a0d6 ]

Add checking for vf id of mailbox, in order to avoid array
out-of-bounds risk.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jian Shen 2024-03-07 09:01:15 +08:00 committed by Greg Kroah-Hartman
parent 454ba1740c
commit be285b8dd2

View File

@ -1124,10 +1124,11 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
req = (struct hclge_mbx_vf_to_pf_cmd *)desc->data; req = (struct hclge_mbx_vf_to_pf_cmd *)desc->data;
flag = le16_to_cpu(crq->desc[crq->next_to_use].flag); flag = le16_to_cpu(crq->desc[crq->next_to_use].flag);
if (unlikely(!hnae3_get_bit(flag, HCLGE_CMDQ_RX_OUTVLD_B))) { if (unlikely(!hnae3_get_bit(flag, HCLGE_CMDQ_RX_OUTVLD_B) ||
req->mbx_src_vfid > hdev->num_req_vfs)) {
dev_warn(&hdev->pdev->dev, dev_warn(&hdev->pdev->dev,
"dropped invalid mailbox message, code = %u\n", "dropped invalid mailbox message, code = %u, vfid = %u\n",
req->msg.code); req->msg.code, req->mbx_src_vfid);
/* dropping/not processing this invalid message */ /* dropping/not processing this invalid message */
crq->desc[crq->next_to_use].flag = 0; crq->desc[crq->next_to_use].flag = 0;