net/hns3: fix insecure way to query MAC statistics
authorHuisong Li <lihuisong@huawei.com>
Fri, 28 Jan 2022 02:07:05 +0000 (10:07 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 31 Jan 2022 13:22:21 +0000 (14:22 +0100)
commit6ee07e3cb589145d0f0826f918fd44eb3e160a08
tree6516dcf0cc3ec8aa76adf4320b480e3cb13b9ff1
parente995c91dcc426e83d4d0d6681b8d3dc0d313c655
net/hns3: fix insecure way to query MAC statistics

The query way of MAC statistics in HNS3 PF driver is as following:
1) get MAC statistics register number and calculate descriptor number.
2) use above descriptor number to send command to firmware to query all
   MAC statistics and copy to hns3_mac_stats struct in driver.

The preceding way does not verify the validity of the number of obtained
register, which may cause memory out-of-bounds.

Fixes: 8839c5e202f3 ("net/hns3: support device stats")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
drivers/net/hns3/hns3_ethdev.c
drivers/net/hns3/hns3_ethdev.h
drivers/net/hns3/hns3_stats.c
drivers/net/hns3/hns3_stats.h