linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4] usbnet: Prevents free active kevent
@ 2025-10-22  2:40 Lizhi Xu
  2025-10-24  1:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Lizhi Xu @ 2025-10-22  2:40 UTC (permalink / raw)
  To: samsun1006219
  Cc: kuba, ahmed.zaki, aleksander.lobakin, davem, edumazet, horms,
	kuniyu, linux-kernel, netdev, pabeni, sdf, syzkaller-bugs,
	syzkaller

The root cause of this issue are:
1. When probing the usbnet device, executing usbnet_link_change(dev, 0, 0);
put the kevent work in global workqueue. However, the kevent has not yet
been scheduled when the usbnet device is unregistered. Therefore, executing
free_netdev() results in the "free active object (kevent)" error reported
here.

2. Another factor is that when calling usbnet_disconnect()->unregister_netdev(),
if the usbnet device is up, ndo_stop() is executed to cancel the kevent.
However, because the device is not up, ndo_stop() is not executed.

The solution to this problem is to cancel the kevent before executing
free_netdev().

Fixes: a69e617e533e ("usbnet: Fix linkwatch use-after-free on disconnect")
Reported-by: Sam Sun <samsun1006219@gmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=8bfd7bcc98f7300afb84
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
---
V1 -> V2: update comments for typos
V2 -> V3: add fixes tag
V3 -> V4: move cancel_work_sync to right after unregister_netdev

 drivers/net/usb/usbnet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index bf01f2728531..697cd9d866d3 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1659,6 +1659,8 @@ void usbnet_disconnect (struct usb_interface *intf)
 	net = dev->net;
 	unregister_netdev (net);
 
+	cancel_work_sync(&dev->kevent);
+
 	while ((urb = usb_get_from_anchor(&dev->deferred))) {
 		dev_kfree_skb(urb->context);
 		kfree(urb->sg);
-- 
2.43.0


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

* Re: [PATCH V4] usbnet: Prevents free active kevent
  2025-10-22  2:40 [PATCH V4] usbnet: Prevents free active kevent Lizhi Xu
@ 2025-10-24  1:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-24  1:20 UTC (permalink / raw)
  To: Lizhi Xu
  Cc: samsun1006219, kuba, ahmed.zaki, aleksander.lobakin, davem,
	edumazet, horms, kuniyu, linux-kernel, netdev, pabeni, sdf,
	syzkaller-bugs, syzkaller

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 22 Oct 2025 10:40:07 +0800 you wrote:
> The root cause of this issue are:
> 1. When probing the usbnet device, executing usbnet_link_change(dev, 0, 0);
> put the kevent work in global workqueue. However, the kevent has not yet
> been scheduled when the usbnet device is unregistered. Therefore, executing
> free_netdev() results in the "free active object (kevent)" error reported
> here.
> 
> [...]

Here is the summary with links:
  - [V4] usbnet: Prevents free active kevent
    https://git.kernel.org/netdev/net/c/420c84c330d1

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-10-24  1:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22  2:40 [PATCH V4] usbnet: Prevents free active kevent Lizhi Xu
2025-10-24  1:20 ` patchwork-bot+netdevbpf

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).