All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: qla4xxx: Fix use after free bug in da9150_charger_remove due to race condition
@ 2023-03-09 18:38 Zheng Wang
  2023-03-09 18:46 ` Zheng Hacker
  2023-03-09 21:41 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Zheng Wang @ 2023-03-09 18:38 UTC (permalink / raw)
  To: njavali
  Cc: mrangankar, GR-QLogic-Storage-Upstream, jejb, martin.petersen,
	linux-scsi, linux-kernel, hackerzheng666, 1395428693sheep,
	alex000young, Zheng Wang

In qla4xxx_probe_adapter, &ha->dpc_work is bound with
qla4xxx_do_dpc. qla4xxx_post_aen_work may be called
to start the work.

If we remove the module which will call qla4xxx_remove_adapter
  to make cleanup, there may be a unfinished work. The possible
  sequence is as follows:

Fix it by canceling the work before cleanup in qla4xxx_remove_adapter

CPU0                  CPUc1

                    |qla4xxx_do_dpc
qla4xxx_remove_adapter|
scsi_remove_host  	|
kfree(ha->host)   	|
                    |
                    |   iscsi_host_for_each_session
                    |   //use ha->host
Fixes: afaf5a2d341d ("[SCSI] Initial Commit of qla4xxx")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
 drivers/scsi/qla4xxx/ql4_os.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 005502125b27..d530cc853f43 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -9001,6 +9001,7 @@ static void qla4xxx_remove_adapter(struct pci_dev *pdev)
 	if (!pci_is_enabled(pdev))
 		return;
 
+	cancel_work_sync(&ha->dpc_work);
 	ha = pci_get_drvdata(pdev);
 
 	if (is_qla40XX(ha))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-09 21:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-09 18:38 [PATCH] scsi: qla4xxx: Fix use after free bug in da9150_charger_remove due to race condition Zheng Wang
2023-03-09 18:46 ` Zheng Hacker
2023-03-09 21:41 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.