Skip to content

Commit 4e0fd1d

Browse files
Yufeng Mogregkh
authored andcommitted
net: hns3: check queue id range before using
[ Upstream commit 63b1279 ] The input parameters may not be reliable. Before using the queue id, we should check this parameter. Otherwise, memory overwriting may occur. Fixes: d341001 ("net: hns3: refactor the mailbox message between PF and VF") Signed-off-by: Yufeng Mo <moyufeng@huawei.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ca43599 commit 4e0fd1d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,17 @@ static void hclge_get_queue_id_in_pf(struct hclge_vport *vport,
581581
struct hclge_mbx_vf_to_pf_cmd *mbx_req,
582582
struct hclge_respond_to_vf_msg *resp_msg)
583583
{
584+
struct hnae3_handle *handle = &vport->nic;
585+
struct hclge_dev *hdev = vport->back;
584586
u16 queue_id, qid_in_pf;
585587

586588
memcpy(&queue_id, mbx_req->msg.data, sizeof(queue_id));
589+
if (queue_id >= handle->kinfo.num_tqps) {
590+
dev_err(&hdev->pdev->dev, "Invalid queue id(%u) from VF %u\n",
591+
queue_id, mbx_req->mbx_src_vfid);
592+
return;
593+
}
594+
587595
qid_in_pf = hclge_covert_handle_qid_global(&vport->nic, queue_id);
588596
memcpy(resp_msg->data, &qid_in_pf, sizeof(qid_in_pf));
589597
resp_msg->len = sizeof(qid_in_pf);

0 commit comments

Comments
 (0)