Skip to contentSkip to conversation

net/ncsi: Disable the ncsi work before freeing the associated structure

PATCH Applied Eddie James 2 participants 2 messages Sep 25, 2024 – Oct 3, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/ncsi: Disable the ncsi work before freeing the associated structure

The work function can run after the ncsi device is freed, resulting in use-after-free bugs or kernel panic.

Fixes 2d283bdd079c ("net/ncsi: Resource management")

---
Changes since v1:
- Use disable_work_sync instead of cancel_work_sync

 net/ncsi/ncsi-manage.c | 2 ++
 1 file changed, 2 insertions(+)
net/ncsi/ncsi-manage.c +2 -0
index 5ecf611c8820..5cf55bde366d 100644
@@ -1954,6 +1954,8 @@ void ncsi_unregister_dev(struct ncsi_dev *nd)
 	list_del_rcu(&ndp->node);
 	spin_unlock_irqrestore(&ncsi_dev_lock, flags);
 
+	disable_work_sync(&ndp->work);
+
 	kfree(ndp);
 }
 EXPORT_SYMBOL_GPL(ncsi_unregister_dev);
Signature · 1 line
2.43.0
#1 lore raw
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Wed, 25 Sep 2024 10:55:23 -0500 you wrote:

The work function can run after the ncsi device is freed, resulting in use-after-free bugs or kernel panic.

Fixes 2d283bdd079c ("net/ncsi: Resource management")

---
Changes since v1:
- Use disable_work_sync instead of cancel_work_sync

[...]

Here is the summary with links:
- [v2] net/ncsi: Disable the ncsi work before freeing the associated structure

    https://git.kernel.org/netdev/net/c/a0ffa68c70b3

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html