* [PATCH RESEND] scsi: message: mptlan: Fix use after free bug in mptlan_remove due to race condition
@ 2023-03-18 8:16 Zheng Wang
0 siblings, 0 replies; 2+ messages in thread
From: Zheng Wang @ 2023-03-18 8:16 UTC (permalink / raw)
To: sathya.prakash
Cc: sreekanth.reddy, suganath-prabu.subramani, MPT-FusionLinux.pdl,
linux-scsi, linux-kernel, hackerzheng666, 1395428693sheep,
alex000young, Zheng Wang
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@163.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH RESEND] scsi: message: mptlan: Fix use after free bug in mptlan_remove due to race condition
@ 2023-04-13 7:47 Zheng Wang
0 siblings, 0 replies; 2+ messages in thread
From: Zheng Wang @ 2023-04-13 7:47 UTC (permalink / raw)
To: sathya.prakash
Cc: sreekanth.reddy, suganath-prabu.subramani, MPT-FusionLinux.pdl,
linux-scsi, linux-kernel, hackerzheng666, 1395428693sheep,
alex000young, Zheng Wang
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@163.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-13 7:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-18 8:16 [PATCH RESEND] scsi: message: mptlan: Fix use after free bug in mptlan_remove due to race condition Zheng Wang
2023-04-13 7:47 Zheng Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).