From 822d3055220db532e4f60ea129c252f88dbc98c4 Mon Sep 17 00:00:00 2001 From: Haibin Lu Date: Wed, 13 Nov 2024 18:45:27 +0800 Subject: [PATCH] HNS3: Add the reliability check of guid_tbl_space. driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IB6YMX CVE: NA ----------------------------------------------------------- When the current code obtains the real guid tbl size, if guid_tbl_space is less than VPORT_NUM, the driver stub value is returned. However, the actual size of the available guid table is smaller than the value of this parameter. Although this does not affect the function (if the table is full, promiscuous will be enabled), debugfs will be affected, users will be misunderstood, and the DFX capability will be affected. This patch add the reliability check of guid_tbl_space. Fixes: a1799222294b ("UNIC: Support using MC GUID and table management") Signed-off-by: Haibin Lu --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 3 ++- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_debugfs.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index ec4573f067a0..fb4c47333942 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -1144,7 +1144,8 @@ struct hclge_link_mode_bmap { static inline u16 hclge_unic_real_mguid_tbl_size(struct hclge_dev *hdev) { return min(HCLGE_UNIC_MC_GUID_NUM, - hdev->ae_dev->dev_specs.guid_tbl_space - HCLGE_VPORT_NUM); + (hdev->ae_dev->dev_specs.guid_tbl_space < HCLGE_VPORT_NUM ? 0 : + hdev->ae_dev->dev_specs.guid_tbl_space - HCLGE_VPORT_NUM)); } int hclge_set_vport_promisc_mode(struct hclge_vport *vport, bool en_uc_pmc, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_debugfs.c index 00a9d7022e89..26510c97edcf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_debugfs.c @@ -47,11 +47,13 @@ int hclge_dbg_dump_ip_spec(struct hclge_dev *hdev, char *buf, int len) int hclge_dbg_dump_guid_spec(struct hclge_dev *hdev, char *buf, int len) { - u16 mc_guid_tbl_size; + u16 guid_tbl_space = hdev->ae_dev->dev_specs.guid_tbl_space; + u16 mc_guid_tbl_size, func_guid_tbl_size; mc_guid_tbl_size = hclge_unic_real_mguid_tbl_size(hdev); + func_guid_tbl_size = mc_guid_tbl_size ? HCLGE_VPORT_NUM : guid_tbl_space; scnprintf(buf, len, "function guid tbl size: %u\nmc guid tbl size: %u\n", - HCLGE_VPORT_NUM, mc_guid_tbl_size); + func_guid_tbl_size, mc_guid_tbl_size); return 0; } -- Gitee