* [PATCH] USB: hso: fix skb leak on device close and teardown
@ 2026-11-29 14:31 zhengzongmin
2026-11-29 16:52 ` Greg KH
2026-11-30 14:31 ` sashiko-bot
0 siblings, 2 replies; 3+ messages in thread
From: zhengzongmin @ 2026-11-29 14:31 UTC (permalink / raw)
To: linux-usb, netdev; +Cc: linux-kernel
From: zhengzongmin <zhengzongmin8@gmail.com>
Date: Sun, 29 Nov 2026 18:59:36 +0800
Subject: [PATCH] USB: hso: fix skb leak on device close and teardown
hso_net_start_xmit() stashes an outgoing skb in odev->skb_tx_buf when
hso_get_activity() returns -EAGAIN. Neither hso_net_close() nor
hso_free_net_device() frees that skb, so when the device is brought
down or disconnected before it resumes, the skb and its head buffer
are permanently leaked. syzbot hit this with an IPv6 Router
Solicitation packet allocated by ndisc_send_rs().
Free the stashed skb in both paths. dev_kfree_skb() is NULL-safe, so
no extra check is needed, and clear the pointer afterwards.
Reported-by: syzbot+bf62ca9997f43d2fa521@syzkaller.appspotmail.com
Signed-off-by: zhengzongmin <zhengzongmin8@gmail.com>
---
drivers/net/usb/hso.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 71caa37..2f46d51 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -726,6 +726,11 @@ static int hso_net_close()
/* no longer running */
clear_bit(HSO_NET_RUNNING, &odev->flags);
+ /* Release a packet stashed by hso_net_start_xmit() when the device
+ * was busy. Otherwise it leaks when the device is brought down. */
+ dev_kfree_skb(odev->skb_tx_buf);
+ odev->skb_tx_buf = NULL;
+
hso_stop_net_device(odev->parent);
/* done */
@@ -2357,6 +2362,11 @@ static void hso_free_net_device()
if (hso_net->net)
unregister_netdev(hso_net->net);
+ /* A stashed skb may survive hso_net_close() if the device was never
+ * brought up; make sure it is freed on the teardown path too. */
+ dev_kfree_skb(hso_net->skb_tx_buf);
+ hso_net->skb_tx_buf = NULL;
+
/* start freeing */
for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) {
usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]);
--
2.55.0.windows.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] USB: hso: fix skb leak on device close and teardown
2026-11-29 14:31 [PATCH] USB: hso: fix skb leak on device close and teardown zhengzongmin
@ 2026-11-29 16:52 ` Greg KH
2026-11-30 14:31 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-11-29 16:52 UTC (permalink / raw)
To: zhengzongmin; +Cc: linux-usb, netdev, linux-kernel
On Sun, Nov 29, 2026 at 06:31:06AM -0800, zhengzongmin wrote:
> From: zhengzongmin <zhengzongmin8@gmail.com>
> Date: Sun, 29 Nov 2026 18:59:36 +0800
> Subject: [PATCH] USB: hso: fix skb leak on device close and teardown
Why is this in the body of the email?
And full name please.
And how was this tested?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] USB: hso: fix skb leak on device close and teardown
2026-11-29 14:31 [PATCH] USB: hso: fix skb leak on device close and teardown zhengzongmin
2026-11-29 16:52 ` Greg KH
@ 2026-11-30 14:31 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-30 14:31 UTC (permalink / raw)
To: zhengzongmin, linux-usb
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] USB: hso: race between hso_net_close() and hso_resume() on
skb_tx_buf
- [Low] USB: hso: missing Fixes trailer for skb_tx_buf leak fix
--
commit 3d6f9f23f19489f009b13c37018dd2945051ad93
Author: zhengzongmin <zhengzongmin8@gmail.com>
> USB: hso: fix skb leak on device close and teardown
>
> hso_net_start_xmit() stashes an outgoing skb in odev->skb_tx_buf when
> hso_get_activity() returns -EAGAIN. Neither hso_net_close() nor
> hso_free_net_device() frees that skb, so when the device is brought
> down or disconnected before it resumes, the skb and its head buffer
> are permanently leaked. syzbot hit this with an IPv6 Router
> Solicitation packet allocated by ndisc_send_rs().
>
> Free the stashed skb in both paths. dev_kfree_skb() is NULL-safe, so
> no extra check is needed, and clear the pointer afterwards.
>
> Reported-by: syzbot+bf62ca9997f43d2fa521@syzkaller.appspotmail.com
> Signed-off-by: zhengzongmin <zhengzongmin8@gmail.com>
[Severity: Low]
Should this bug fix include a Fixes: tag for the commit that introduced
skb_tx_buf stashing:
Fixes: 72dc1c096c70 ("HSO: add option hso driver")
> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index 71caa3764b239..2f46d51269d0a 100644
> --- a/drivers/net/usb/hso.c
> +++ b/drivers/net/usb/hso.c
> @@ -726,6 +726,11 @@ static int hso_net_close(struct net_device *net)
> /* no longer running */
> clear_bit(HSO_NET_RUNNING, &odev->flags);
>
> + /* Release a packet stashed by hso_net_start_xmit() when the device
> + * was busy. Otherwise it leaks when the device is brought down. */
> + dev_kfree_skb(odev->skb_tx_buf);
> + odev->skb_tx_buf = NULL;
[Severity: High]
Can freeing odev->skb_tx_buf here race with hso_resume() and cause a
use-after-free and double free?
When hso_get_activity() returns -EAGAIN during transmit, it schedules
async_get_intf to resume the USB interface. hso_resume() runs under the
USB device PM lock without holding rtnl_lock or any lock shared with
hso_net_close(), and only clears skb_tx_buf after hso_net_start_xmit()
has transmitted and freed it:
drivers/net/usb/hso.c:hso_resume() {
...
if (hso_net->flags & IFF_UP) {
/* First transmit any lingering data,
then restart the device. */
if (hso_net->skb_tx_buf) {
dev_dbg(&iface->dev,
"Transmitting"
" lingering data\n");
hso_net_start_xmit(hso_net->skb_tx_buf,
hso_net->net);
hso_net->skb_tx_buf = NULL;
}
...
}
If the interface is brought down while async_get_intf (or system resume)
is running hso_resume(), both paths can consume the same skb:
CPU0 CPU1 (kworker / async_get_intf)
hso_resume()
if (hso_net->flags & IFF_UP)
skb = hso_net->skb_tx_buf
hso_net_close()
clear_bit(HSO_NET_RUNNING, ...)
dev_kfree_skb(odev->skb_tx_buf)
odev->skb_tx_buf = NULL
hso_net_start_xmit(skb, ...)
memcpy(..., skb->data, skb->len)
<-- use-after-free
dev_kfree_skb(skb)
<-- double free
--
Sashiko AI review · https://sashiko.dev/#/patchset/6b0c372a.1800fd7e.25977e.57fb@mx.google.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 14:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 14:31 [PATCH] USB: hso: fix skb leak on device close and teardown zhengzongmin
2026-11-29 16:52 ` Greg KH
2026-11-30 14:31 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox