From: sashiko-bot@kernel.org
To: "Aibing Chen" <chenaibing@cmss.chinamobile.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net v3] net: hso: fix stashed tx skb leak and replay race
Date: Wed, 18 Nov 2026 08:47:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-220508@kernel.org> (raw)
In-Reply-To: <20261117084732.297-1-chenaibing@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: hso: race on skb_tx_buf and unlocked
hso_net_start_xmit() in hso_resume()
--
commit 0ff5cfff5d764799a7628578e9a708235e69853a
Author: Aibing Chen <chenaibing@cmss.chinamobile.com>
net: hso: fix stashed tx skb leak and replay race
This commit takes the stashed TX skb with xchg() in hso_net_close() and
hso_resume() and adds a per-interface mutex to serialize replay during USB
resume against interface close.
Link: https://lore.kernel.org/all/6af74e31.fe96acdb.12252b.0009.GAE@google.com/
> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index 71caa3764b239..43884234c4d8f 100644
> --- a/drivers/net/usb/hso.c
> +++ b/drivers/net/usb/hso.c
[ ... ]
> @@ -3051,21 +3069,28 @@ static int hso_resume(struct usb_interface *iface)
> if (network_table[i] &&
> (network_table[i]->interface == iface)) {
> hso_net = dev2net(network_table[i]);
> - if (hso_net->flags & IFF_UP) {
> - /* First transmit any lingering data,
> - then restart the device. */
> - if (hso_net->skb_tx_buf) {
> + mutex_lock(&hso_net->tx_replay_lock);
> +
> + /*
> + * First transmit any lingering data, then restart
> + * the device.
> + */
> + if (test_bit(HSO_NET_RUNNING, &hso_net->flags)) {
> + skb = xchg(&hso_net->skb_tx_buf, NULL);
> + if (skb) {
> 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;
> + hso_net_start_xmit(skb, hso_net->net);
> }
[Severity: Medium]
Does hso_resume() still need netif_tx_lock_bh(hso_net->net) around the
skb_tx_buf xchg() and hso_net_start_xmit() call?
tx_replay_lock serializes hso_resume() with hso_net_close(), but
hso_net_start_xmit() runs under the netdev TX lock without taking
tx_replay_lock:
drivers/net/usb/hso.c:hso_net_start_xmit() {
netif_stop_queue(net);
if (hso_get_activity(odev->parent) == -EAGAIN) {
odev->skb_tx_buf = skb;
return NETDEV_TX_OK;
}
When the device is suspended, hso_get_activity() schedules async_get_intf
and checks usb->state != USB_STATE_CONFIGURED before returning -EAGAIN. If
hso_resume() runs between that check and the skb_tx_buf assignment, nothing
serializes the two paths:
CPU0 CPU1
hso_net_start_xmit()
netif_stop_queue(net)
hso_get_activity() -> -EAGAIN
schedule_work(&async_get_intf)
usb_resume_both()
udev->state = USB_STATE_CONFIGURED
hso_resume()
xchg(&hso_net->skb_tx_buf, NULL)
-> NULL
odev->skb_tx_buf = skb; <-- TX queue wedged
Because usb->state is already USB_STATE_CONFIGURED and no TX URB is in
flight, write_bulk_callback() never runs to wake the queue or drop the
activity reference, leaving the TX queue stopped and the runtime PM
reference leaked.
In addition, when hso_resume() does obtain a stashed skb, calling
hso_net_start_xmit() without netif_tx_lock_bh() allows another CPU to enter
hso_net_start_xmit() concurrently if usb_submit_urb() fails or completes
before the replay call returns.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117084732.297-1-chenaibing@cmss.chinamobile.com?part=1
prev parent reply other threads:[~2026-11-18 8:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 9:31 [PATCH] net: hso: fix tx skb leak when the device stops Aibing Chen
2026-11-15 9:31 ` sashiko-bot
2026-11-15 10:16 ` [PATCH v2] net: hso: fix tx skb leak and a race on the stashed skb Aibing Chen
2026-11-16 10:16 ` sashiko-bot
2026-11-16 10:23 ` netdev-bot+sashiko
2026-11-15 21:20 ` [PATCH] net: hso: fix tx skb leak when the device stops netdev-bot+sashiko
2026-11-17 8:47 ` [PATCH net v3] net: hso: fix stashed tx skb leak and replay race Aibing Chen
2026-11-18 8:47 ` sashiko-bot [this message]
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=sashiko-outbox-220508@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chenaibing@cmss.chinamobile.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.