Commit 55c81df5 authored by Yihang Li's avatar Yihang Li Committed by xia-bing1
Browse files

scsi: hisi_sas: Adjust priority of registering and exiting debugfs for security

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB5FF2


CVE: NA

---------------------------------------------------------------------

Spec says at least 5us between two H2D FIS when do soft reset, but be
To be safe, we should register debugfs at the last stage of driver
initialization and then unregister debugfs at the first stage of driver
uninstallation.

Fixes: 623a4b6d ("scsi: hisi_sas: Move debugfs code to v3 hw driver")
Signed-off-by: default avatarYihang Li <liyihang9@huawei.com>
Link: https://lore.kernel.org/r/20241008021822.2617339-2-liyihang9@huawei.com


Reviewed-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarBing Xia <xiabing12@h-partners.com>
parent 6df3ef8c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2611,10 +2611,10 @@ static __init int hisi_sas_init(void)

static __exit void hisi_sas_exit(void)
{
	sas_release_transport(hisi_sas_stt);

	if (hisi_sas_debugfs_enable)
		debugfs_remove(hisi_sas_debugfs_dir);

	sas_release_transport(hisi_sas_stt);
}

module_init(hisi_sas_init);
+6 −11
Original line number Diff line number Diff line
@@ -4998,16 +4998,13 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
					    SHOST_DIX_GUARD_CRC);
	}

	if (hisi_sas_debugfs_enable)
		debugfs_init_v3_hw(hisi_hba);

	rc = interrupt_preinit_v3_hw(hisi_hba);
	if (rc)
		goto err_out_undo_debugfs;
		goto err_out_free_host;

	rc = scsi_add_host(shost, dev);
	if (rc)
		goto err_out_undo_debugfs;
		goto err_out_free_host;

	rc = sas_register_ha(sha);
	if (rc)
@@ -5018,6 +5015,8 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
		goto err_out_unregister_ha;

	scsi_scan_host(shost);
	if (hisi_sas_debugfs_enable)
		debugfs_init_v3_hw(hisi_hba);

	pm_runtime_set_autosuspend_delay(dev, 5000);
	pm_runtime_use_autosuspend(dev);
@@ -5038,9 +5037,6 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	sas_unregister_ha(sha);
err_out_remove_host:
	scsi_remove_host(shost);
err_out_undo_debugfs:
	if (hisi_sas_debugfs_enable)
		debugfs_exit_v3_hw(hisi_hba);
err_out_free_host:
	hisi_sas_free(hisi_hba);
	scsi_host_put(shost);
@@ -5072,6 +5068,8 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev)
	struct Scsi_Host *shost = sha->shost;

	pm_runtime_get_noresume(dev);
	if (hisi_sas_debugfs_enable)
		debugfs_exit_v3_hw(hisi_hba);

	sas_unregister_ha(sha);
	flush_workqueue(hisi_hba->wq);
@@ -5079,9 +5077,6 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev)

	hisi_sas_v3_destroy_irqs(pdev, hisi_hba);
	hisi_sas_free(hisi_hba);
	if (hisi_sas_debugfs_enable)
		debugfs_exit_v3_hw(hisi_hba);

	scsi_host_put(shost);
}