* [PATCH] net/ncsi: Cancel the ncsi work before freeing the associated structure
@ 2024-09-17 19:12 Eddie James
2024-09-24 9:10 ` Paolo Abeni
0 siblings, 1 reply; 2+ messages in thread
From: Eddie James @ 2024-09-17 19:12 UTC (permalink / raw)
To: sam
Cc: davem, edumazet, kuba, pabeni, gwshan, joel, netdev, linux-kernel,
eajames
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")
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
net/ncsi/ncsi-manage.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 5ecf611c8820..3eda24eac668 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -1954,6 +1954,8 @@ void ncsi_unregister_dev(struct ncsi_dev *nd)
list_del_rcu(&ndp->node);
spin_unlock_irqrestore(&ncsi_dev_lock, flags);
+ cancel_work_sync(&ndp->work);
+
kfree(ndp);
}
EXPORT_SYMBOL_GPL(ncsi_unregister_dev);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net/ncsi: Cancel the ncsi work before freeing the associated structure
2024-09-17 19:12 [PATCH] net/ncsi: Cancel the ncsi work before freeing the associated structure Eddie James
@ 2024-09-24 9:10 ` Paolo Abeni
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2024-09-24 9:10 UTC (permalink / raw)
To: Eddie James, sam
Cc: davem, edumazet, kuba, gwshan, joel, netdev, linux-kernel
On 9/17/24 21:12, Eddie James 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")
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> ---
> net/ncsi/ncsi-manage.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
> index 5ecf611c8820..3eda24eac668 100644
> --- a/net/ncsi/ncsi-manage.c
> +++ b/net/ncsi/ncsi-manage.c
> @@ -1954,6 +1954,8 @@ void ncsi_unregister_dev(struct ncsi_dev *nd)
> list_del_rcu(&ndp->node);
> spin_unlock_irqrestore(&ncsi_dev_lock, flags);
>
> + cancel_work_sync(&ndp->work);
Possibly disable_work_sync(), just to be on the safe side?
Thanks,
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-24 9:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17 19:12 [PATCH] net/ncsi: Cancel the ncsi work before freeing the associated structure Eddie James
2024-09-24 9:10 ` Paolo Abeni
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).