Peiyang Wang (1): net: hns3: release PTP resources if pf initialization failed
Yonglong Liu (3): net: hns3: fix kernel crash when devlink reload during pf initialization net: hns3: fix kernel crash when devlink reload during vf initialization net: hns3: fix kernel crash when devlink reload during initialization
.../hisilicon/hns3/hns3pf/hclge_devlink.c | 5 +++-- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 16 ++++++++-------- .../hisilicon/hns3/hns3vf/hclgevf_devlink.c | 5 +++-- .../hisilicon/hns3/hns3vf/hclgevf_main.c | 10 ++++------ 4 files changed, 18 insertions(+), 18 deletions(-)
From: Yonglong Liu liuyonglong@huawei.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9TM2X CVE: CVE-2024-36021
----------------------------------------------------------------------
The devlink reload process will access the hardware resources, but the register operation is before the hardware initialize done, so, if process the devlink reload during initializetion, may lead the kernel crash. This patch check whether the NIC is initialized to fix the problem.
Fixes: 2cd7213c2dc4 ("net: hns3: add support for registering devlink for PF") Signed-off-by: Yonglong Liu liuyonglong@huawei.com Signed-off-by: Ye Bin yebin10@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c index 65802ecf848f..28079c246275 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c @@ -45,8 +45,9 @@ static int hclge_devlink_reload_down(struct devlink *devlink, bool netns_change, struct pci_dev *pdev = hdev->pdev; int ret;
- if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) { - dev_err(&pdev->dev, "reset is handling\n"); + if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) || + !test_bit(HCLGE_STATE_NIC_REGISTERED, &hdev->state)) { + dev_err(&pdev->dev, "reset is handling or driver removed\n"); return -EBUSY; }
From: Yonglong Liu liuyonglong@huawei.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9TM2X CVE: CVE-2024-36021
Reference: https://gitee.com/openeuler/kernel/commit/f18e4f63130c196d6a28a0db0af2093d82...
--------------------------------
The devlink reload process will access the hardware resources, but the register operation is before the hardware initialize done, so, if process the devlink reload during initializetion, may lead the kernel crash. This patch check whether the NIC is initialized to fix the problem.
Fixes: c3141771b0c3 ("net: hns3: add support for registering devlink for VF") Signed-off-by: Yonglong Liu liuyonglong@huawei.com Signed-off-by: Jialin Zhang zhangjialin11@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c index d209a17927e5..ca8d2287e4ba 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c @@ -46,8 +46,9 @@ static int hclgevf_devlink_reload_down(struct devlink *devlink, struct pci_dev *pdev = hdev->pdev; int ret;
- if (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) { - dev_err(&pdev->dev, "reset is handling\n"); + if (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state) || + !test_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state)) { + dev_err(&pdev->dev, "reset is handling or driver removed\n"); return -EBUSY; }
From: Peiyang Wang wangpeiyang1@huawei.com
mainline inclusion from mainline-v6.9-rc4 commit 950aa42399893a170d9b57eda0e4a3ff91fd8b70 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9U3H2 CVE: CVE-2024-36900
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
----------------------------------------------------
During the PF initialization process, hclge_update_port_info may return an error code for some reason. At this point, the ptp initialization has been completed. To void memory leaks, the resources that are applied by ptp should be released. Therefore, when hclge_update_port_info returns an error code, hclge_ptp_uninit is called to release the corresponding resources.
Fixes: eaf83ae59e18 ("net: hns3: add querying fec ability from firmware") Signed-off-by: Peiyang Wang wangpeiyang1@huawei.com Signed-off-by: Jijie Shao shaojijie@huawei.com Reviewed-by: Hariprasad Kelam hkelam@marvell.com Signed-off-by: Paolo Abeni pabeni@redhat.com Signed-off-by: chenyi chenyi211@huawei.com Conflicts: drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c [fix context diff] Signed-off-by: Ye Bin yebin10@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index af366b9e6b7f..608019d1d2bc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -12383,7 +12383,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
ret = hclge_update_port_info(hdev); if (ret) - goto err_sysfs_unregister; + goto err_ptp_uninit;
INIT_KFIFO(hdev->mac_tnl_log);
@@ -12433,6 +12433,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
return 0;
+err_ptp_uninit: + hclge_ptp_uninit(hdev); err_sysfs_unregister: hclge_unregister_sysfs(hdev); err_mdiobus_unreg:
From: Yonglong Liu liuyonglong@huawei.com
mainline inclusion from mainline-v6.9 commit 35d92abfbad88cf947c010baf34b075e40566095 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9U3H2 CVE: CVE-2024-36900
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
The devlink reload process will access the hardware resources, but the register operation is done before the hardware is initialized. So, processing the devlink reload during initialization may lead to kernel crash.
This patch fixes this by registering the devlink after hardware initialization. Fixes: cd6242991d2e ("net: hns3: add support for registering devlink for VF") Fixes: 93305b77ffcb ("net: hns3: fix kernel crash when devlink reload during pf initialization") Signed-off-by: Yonglong Liu liuyonglong@huawei.com Signed-off-by: Jijie Shao shaojijie@huawei.com Signed-off-by: Paolo Abeni pabeni@redhat.com Conflicts: drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c [fix context diff] Signed-off-by: Ye Bin yebin10@huawei.com --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 12 +++++------- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 10 ++++------ 2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 608019d1d2bc..7d139bfb44cc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -12243,14 +12243,10 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) if (ret) goto out;
- ret = hclge_devlink_init(hdev); - if (ret) - goto err_pci_uninit; - /* Firmware command queue initialize */ ret = hclge_comm_cmd_queue_init(hdev->pdev, &hdev->hw.hw); if (ret) - goto err_devlink_uninit; + goto err_pci_uninit;
/* Firmware command initialize */ ret = hclge_comm_cmd_init(hdev->ae_dev, &hdev->hw.hw, &hdev->fw_version, @@ -12423,6 +12419,10 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) dev_warn(&pdev->dev, "failed to wake on lan init, ret = %d\n", ret);
+ ret = hclge_devlink_init(hdev); + if (ret) + goto err_ptp_uninit; + hclge_state_init(hdev); hdev->last_reset_time = jiffies;
@@ -12446,8 +12446,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) pci_free_irq_vectors(pdev); err_cmd_uninit: hclge_comm_cmd_uninit(hdev->ae_dev, &hdev->hw.hw); -err_devlink_uninit: - hclge_devlink_uninit(hdev); err_pci_uninit: pcim_iounmap(pdev, hdev->hw.hw.io_base); pci_clear_master(pdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index b5738a7e260a..cdd0c1583b9e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -2952,10 +2952,6 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) if (ret) return ret;
- ret = hclgevf_devlink_init(hdev); - if (ret) - goto err_devlink_init; - ret = hclge_comm_cmd_queue_init(hdev->pdev, &hdev->hw.hw); if (ret) goto err_cmd_queue_init; @@ -3050,6 +3046,10 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
hclgevf_init_rxd_adv_layout(hdev);
+ ret = hclgevf_devlink_init(hdev); + if (ret) + goto err_config; + set_bit(HCLGEVF_STATE_SERVICE_INITED, &hdev->state);
hdev->last_reset_time = jiffies; @@ -3068,8 +3068,6 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) err_cmd_init: hclge_comm_cmd_uninit(hdev->ae_dev, &hdev->hw.hw); err_cmd_queue_init: - hclgevf_devlink_uninit(hdev); -err_devlink_init: hclgevf_pci_uninit(hdev); clear_bit(HCLGEVF_STATE_IRQ_INITED, &hdev->state); return ret;
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/8672 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/5...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/8672 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/5...