* [PATCH net] net: usb: ipheth: fix carrier_work UAF on disconnect
@ 2026-07-24 13:42 Doruk Tan Ozturk
2026-07-31 0:55 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Doruk Tan Ozturk @ 2026-07-24 13:42 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andrew Lunn
Cc: Alexander Kappner, linux-usb, netdev, linux-kernel, stable
ipheth_sndbulk_callback() re-arms the carrier-check work on any non-zero
URB status:
else
schedule_delayed_work(&dev->carrier_work, 0);
ipheth_disconnect() drains that work via unregister_netdev() ->
ipheth_close() -> cancel_delayed_work_sync(), and only then kills the URBs
with ipheth_kill_urbs(). usb_kill_urb() completes any in-flight TX URB
synchronously with -ENOENT, so ipheth_sndbulk_callback() runs after the
drain and re-arms carrier_work. free_netdev() then frees the netdev
whose private area embeds carrier_work, and the pending
ipheth_carrier_check_work() dereferences the freed device, a
use-after-free on unplug while a TX URB is in flight.
Drain carrier_work again after the URB source is stopped and before the
netdev is freed.
Found by 0sec (https://0sec.ai) using automated source analysis; not
runtime-reproduced.
Fixes: bb1b40c7cb86 ("usbnet: ipheth: prevent TX queue timeouts when device not ready")
Cc: stable@vger.kernel.org
Assisted-by: 0sec:multi-model
Signed-off-by: Doruk Tan Ozturk <doruk@0sec.ai>
---
drivers/net/usb/ipheth.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
index bb1364f85bd1..fdddd761f83b 100644
--- a/drivers/net/usb/ipheth.c
+++ b/drivers/net/usb/ipheth.c
@@ -672,6 +672,15 @@ static void ipheth_disconnect(struct usb_interface *intf)
if (dev != NULL) {
unregister_netdev(dev->net);
ipheth_kill_urbs(dev);
+ /*
+ * ipheth_sndbulk_callback() re-arms carrier_work on the
+ * -ENOENT completion delivered by the usb_kill_urb() in
+ * ipheth_kill_urbs(), after ipheth_close() (via
+ * unregister_netdev()) already drained it. Drain it again
+ * once the URB source is stopped, before free_netdev() frees
+ * the netdev whose private area embeds carrier_work.
+ */
+ cancel_delayed_work_sync(&dev->carrier_work);
ipheth_free_urbs(dev);
kfree(dev->ctrl_buf);
free_netdev(dev->net);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net: usb: ipheth: fix carrier_work UAF on disconnect
2026-07-24 13:42 [PATCH net] net: usb: ipheth: fix carrier_work UAF on disconnect Doruk Tan Ozturk
@ 2026-07-31 0:55 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-07-31 0:55 UTC (permalink / raw)
To: Doruk Tan Ozturk
Cc: David S . Miller, Eric Dumazet, Paolo Abeni, Andrew Lunn,
Alexander Kappner, linux-usb, netdev, linux-kernel, stable
On Fri, 24 Jul 2026 15:42:50 +0200 Doruk Tan Ozturk wrote:
> ipheth_sndbulk_callback() re-arms the carrier-check work on any non-zero
> URB status:
>
> else
> schedule_delayed_work(&dev->carrier_work, 0);
>
> ipheth_disconnect() drains that work via unregister_netdev() ->
> ipheth_close() -> cancel_delayed_work_sync(), and only then kills the URBs
> with ipheth_kill_urbs(). usb_kill_urb() completes any in-flight TX URB
> synchronously with -ENOENT, so ipheth_sndbulk_callback() runs after the
> drain and re-arms carrier_work. free_netdev() then frees the netdev
> whose private area embeds carrier_work, and the pending
> ipheth_carrier_check_work() dereferences the freed device, a
> use-after-free on unplug while a TX URB is in flight.
>
> Drain carrier_work again after the URB source is stopped and before the
> netdev is freed.
Doesn't look very clean. Maybe we can check netif_running() before
scheduling? Or disable / enable the work.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-31 0:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 13:42 [PATCH net] net: usb: ipheth: fix carrier_work UAF on disconnect Doruk Tan Ozturk
2026-07-31 0:55 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox