From: Doruk Tan Ozturk <doruk@0sec.ai>
To: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Alexander Kappner <agk@godking.net>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH net] net: usb: ipheth: fix carrier_work UAF on disconnect
Date: Fri, 24 Jul 2026 15:42:50 +0200 [thread overview]
Message-ID: <20260724134250.34360-1-doruk@0sec.ai> (raw)
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
next reply other threads:[~2026-07-24 13:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 13:42 Doruk Tan Ozturk [this message]
2026-07-31 0:55 ` [PATCH net] net: usb: ipheth: fix carrier_work UAF on disconnect Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260724134250.34360-1-doruk@0sec.ai \
--to=doruk@0sec.ai \
--cc=agk@godking.net \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox