From: Huazhong Tan <hidden> Date: 2021-02-09 09:11:23
The parameters sent from vf may be unreliable. If these
parameters are used directly, memory overwriting may occur.
So this series adds some checks for this case.
Yufeng Mo (3):
net: hns3: add a check for queue_id in hclge_reset_vf_queue()
net: hns3: add a check for tqp_index in
hclge_get_ring_chain_from_mbx()
net: hns3: add a check for index in hclge_get_rss_key()
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 ++++++
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 29 +++++++++++++++++++---
2 files changed, 32 insertions(+), 4 deletions(-)
--
2.7.4
From: Huazhong Tan <hidden> Date: 2021-02-09 09:11:23
From: Yufeng Mo <redacted>
The queue_id is received from vf, if use it directly,
an out-of-bound issue may be caused, so add a check for
this queue_id before using it in hclge_reset_vf_queue().
Fixes: 1a426f8b40fc ("net: hns3: fix the VF queue reset flow error")
Signed-off-by: Yufeng Mo <redacted>
Signed-off-by: Huazhong Tan <redacted>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 +++++++
1 file changed, 7 insertions(+)
From: Huazhong Tan <hidden> Date: 2021-02-09 09:11:23
From: Yufeng Mo <redacted>
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 <redacted>
Signed-off-by: Huazhong Tan <redacted>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 11 +++++++++++
1 file changed, 11 insertions(+)
@@ -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+*morethanthesizeofrss_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);
From: Huazhong Tan <hidden> Date: 2021-02-09 09:11:23
From: Yufeng Mo <redacted>
The tqp_index is received from vf, if use it directly,
an out-of-bound issue may be caused, so add a check for
this tqp_index before using it in hclge_get_ring_chain_from_mbx().
Fixes: 84e095d64ed9 ("net: hns3: Change PF to add ring-vect binding & resetQ to mailbox")
Signed-off-by: Yufeng Mo <redacted>
Signed-off-by: Huazhong Tan <redacted>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
@@ -158,21 +158,31 @@ static int hclge_get_ring_chain_from_mbx(structhclge_vport*vport){structhnae3_ring_chain_node*cur_chain,*new_chain;+structhclge_dev*hdev=vport->back;intring_num;-inti=0;+inti;ring_num=req->msg.ring_num;if(ring_num>HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM)return-ENOMEM;+for(i=0;i<ring_num;i++){+if(req->msg.param[i].tqp_index>=vport->nic.kinfo.rss_size){+dev_err(&hdev->pdev->dev,"tqp index(%u) is out of range(0-%u)\n",+req->msg.param[i].tqp_index,+vport->nic.kinfo.rss_size-1);+return-EINVAL;+}+}+hnae3_set_bit(ring_chain->flag,HNAE3_RING_TYPE_B,-req->msg.param[i].ring_type);+req->msg.param[0].ring_type);ring_chain->tqp_index=hclge_get_queue_id(vport->nic.kinfo.tqp-[req->msg.param[i].tqp_index]);+[req->msg.param[0].tqp_index]);hnae3_set_field(ring_chain->int_gl_idx,HNAE3_RING_GL_IDX_M,-HNAE3_RING_GL_IDX_S,req->msg.param[i].int_gl_index);+HNAE3_RING_GL_IDX_S,req->msg.param[0].int_gl_index);cur_chain=ring_chain;
Hello:
This series was applied to netdev/net.git (refs/heads/master):
On Tue, 9 Feb 2021 17:03:04 +0800 you wrote:
The parameters sent from vf may be unreliable. If these
parameters are used directly, memory overwriting may occur.
So this series adds some checks for this case.
Yufeng Mo (3):
net: hns3: add a check for queue_id in hclge_reset_vf_queue()
net: hns3: add a check for tqp_index in
hclge_get_ring_chain_from_mbx()
net: hns3: add a check for index in hclge_get_rss_key()
[...]