Skip to content

Commit 63b1279

Browse files
Yufeng Modavem330
authored andcommitted
net: hns3: check queue id range before using
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 <[email protected]> Signed-off-by: Guangbin Huang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 311c0aa commit 63b1279

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,17 @@ static void hclge_get_queue_id_in_pf(struct hclge_vport *vport,
590590
struct hclge_mbx_vf_to_pf_cmd *mbx_req,
591591
struct hclge_respond_to_vf_msg *resp_msg)
592592
{
593+
struct hnae3_handle *handle = &vport->nic;
594+
struct hclge_dev *hdev = vport->back;
593595
u16 queue_id, qid_in_pf;
594596

595597
memcpy(&queue_id, mbx_req->msg.data, sizeof(queue_id));
598+
if (queue_id >= handle->kinfo.num_tqps) {
599+
dev_err(&hdev->pdev->dev, "Invalid queue id(%u) from VF %u\n",
600+
queue_id, mbx_req->mbx_src_vfid);
601+
return;
602+
}
603+
596604
qid_in_pf = hclge_covert_handle_qid_global(&vport->nic, queue_id);
597605
memcpy(resp_msg->data, &qid_in_pf, sizeof(qid_in_pf));
598606
resp_msg->len = sizeof(qid_in_pf);

0 commit comments

Comments
 (0)