[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230413074715.237471-1-zyytlz.wz@163.com>
Date: Thu, 13 Apr 2023 15:47:15 +0800
From: Zheng Wang <zyytlz.wz@....com>
To: sathya.prakash@...adcom.com
Cc: sreekanth.reddy@...adcom.com,
suganath-prabu.subramani@...adcom.com,
MPT-FusionLinux.pdl@...adcom.com, linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org, hackerzheng666@...il.com,
1395428693sheep@...il.com, alex000young@...il.com,
Zheng Wang <zyytlz.wz@....com>
Subject: [PATCH RESEND] scsi: message: mptlan: Fix use after free bug in mptlan_remove due to race condition
In mptlan_probe, it called mpt_register_lan_device and bound
&priv->post_buckets_task with mpt_lan_post_receive_buckets_work.
When it calls lan_reply, it will finally call
mpt_lan_wake_post_buckets_task to start the work.
When we call mptlan_remove to remove the driver, there
may be a sequence as follows:
Fix it by finishing the work before cleanup in mptlan_remove
CPU0 CPU1
|mpt_lan_post_receive_buckets_work
mptlan_remove |
free_netdev |
kfree(dev); |
|
| dev->mtu
| //use
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Zheng Wang <zyytlz.wz@....com>
---
drivers/message/fusion/mptlan.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 142eb5d5d9df..de2e7bcf4784 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -1433,7 +1433,9 @@ mptlan_remove(struct pci_dev *pdev)
{
MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
struct net_device *dev = ioc->netdev;
+ struct mpt_lan_priv *priv = netdev_priv(dev);
+ cancel_delayed_work_sync(&priv->post_buckets_task);
if(dev != NULL) {
unregister_netdev(dev);
free_netdev(dev);
--
2.25.1
Powered by blists - more mailing lists