From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796052498; b=mERFsUuNWcuOpZUp6FCnWHoTP+AycPB/fOR8mOVWTHm6NBla1481mcF3C3gUbcqR9rZ0 9szlRJnzQAtGOVPpm2TBVGtKkkXjIKJEdITQTqgwAAnFJ2ny6jD1HjMDJYB0XxWwkl0pd 9WO/N9dWSF4GGJjBEFEj7UpvdbXN+bRU2mPkwfr7gGv0eia2WMSBpcz5/4ZLlQ3CyudJc Tpt9rvGun/qbCI/h+p0+32HAP2WqSjkSv4Zmg63VBowJ3hnjVVksVIyhQbRlhWEsm6oms qV/4beKqNGlWJcJ8+HEla1AdcWpjzA4UNXHYlmstkuB1JsTTxr7i4gYqWwZvZBvVErw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796052498; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=R+Saybbu6bsku3qjE/p93vUCjdTyJj1A3s3hDYSWIwo=; b=UGFbhYZid1ygE71CaPfhd6h7VBS8+YM5Z7377nxSe5NqDNM3A7m3ecmK6yzmHX1u2DLh HjSlvbVPc78yHV28JL4FPvuRjTuqSEpNgxZZPGKlWs5lCTeRN6MJ8vjc8vRP6bJeaYUmP TEBwU2PyF4u4Ij0TMBWxzAzJO6TN01G5BSV1YGKVLOh52KvQ0vs6V8nVUS5A3T7TIgWXL 8FU4SRmSGfsPmI6ShMkixpXgwPp/tuaeUPyOLWtsHwjc9dAqwG3zanlw7/Er8oPKZwdI+ HhwqioGriAowgBp5/ydPRMfmxh6hbDQkgigrYFBaGLIuX2OyVMNYNtaFquYM0aXf0AQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SEHx38W2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1989606A335; Mon, 30 Nov 2026 15:28:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SEHx38W2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14B751F00899; Mon, 30 Nov 2026 15:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796052498; bh=R+Saybbu6bsku3qjE/p93vUCjdTyJj1A3s3hDYSWIwo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SEHx38W2Yo71wD0A/cUXb8CBSEG2kSU4yeE9UHUx25LVhoJBZuOAriVMdNcCs6GF4 AphoXgr8AEikWS6bz2WVYsIzru5caZswtEzSKChJnAc88V7t62fVyPb9fLFpnJ63v7 70mFuI64JNB71kW34zgVUHASxMi3D3OwUESpTjnivrT76iDR03CxV4ox36k36m1aEC SzwlFK4xJKZ15WVoJjYxqn7Rmg9km+jSO7UVdzG5PksRTsLx8qhAsGS7yeCkNlG3+3 NXOydPfnktXwPjhdiQwarkXUuN+SeOEX4k+x3I3/Df/0lgtj68B51oX7WT8yz3cKBa 9JrtILdHcBYDA== Subject: Re: [PATCH] USB: hso: fix skb leak on device close and teardown From: netdev-bot+sashiko@kernel.org To: zhengzongmin8@gmail.com Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kuba@kernel.org Date: Mon, 30 Nov 2026 15:28:17 +0000 Message-ID: <179605249757.3146.4073347231353749717@kernel.org> In-Reply-To: <6b0c372a.1800fd7e.25977e.57fb@mx.google.com> References: <6b0c372a.1800fd7e.25977e.57fb@mx.google.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 (2) · Low: 3 (1) If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The new free of odev->skb_tx_buf in hso_net_close() (drivers/net/usb/hso.c:731-732) is not synchronized with hso_resume()… - [Low] The patch fixes a syzbot-reported skb leak that every stable kernel with this driver has, but it has no Fixes: tag and no Cc:… - [Low] The comment added in hso_free_net_device() (lines 2365-2366) says a stashed skb "may survive hso_net_close() if the device was never… - [Low] Both new free sites (hso_net_close() line 731 and hso_free_net_device() line 2367) release a packet that was never… Pre-existing issues: - [Medium] This problem wasn't introduced by this patch, but hso_resume() can lose the stashed skb. - [Medium] This problem wasn't introduced by this patch, but stashing an skb leaves a runtime-PM reference held after the interface goes down. - [Low] This problem wasn't introduced by this patch, but hso_resume() (line 3064) tests `hso_net->flags & IFF_UP`. -- USB: hso: fix skb leak on device close and teardown This patch frees the skb that hso_net_start_xmit() stashes in skb_tx_buf when hso_get_activity() returns -EAGAIN. The free is added to both hso_net_close() and hso_free_net_device(), to fix a syzbot-reported leak of an IPv6 Router Solicitation skb. > Reported-by: syzbot+bf62ca9997f43d2fa521@syzkaller.appspotmail.com > Signed-off-by: zhengzongmin [Severity: Low] Should this have a Fixes: tag and Cc: stable? The logic in hso_net_start_xmit() that stashes the skb without ever freeing it seems to come from the original driver commit: Fixes: 72dc1c096c70 ("HSO: add option hso driver") Also, the "USB: hso:" subject prefix doesn't follow the netdev convention for drivers/net/usb/. Would "net: usb: hso:" fit the net tree better? > 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 this free race with hso_resume(), which also uses this skb? By the time hso_net_start_xmit() stashes the skb, hso_get_activity() has already scheduled async_get_intf: hso_get_activity() { if (hso_dev->usb->state == USB_STATE_SUSPENDED) { if (!hso_dev->is_active) { hso_dev->is_active = 1; schedule_work(&hso_dev->async_get_intf); } } ... } That worker calls usb_autopm_get_interface(). This runtime-resumes the device and runs hso_resume(), which holds neither RTNL nor any driver lock: hso_resume() { ... if (hso_net->flags & IFF_UP) { ... if (hso_net->skb_tx_buf) { ... hso_net_start_xmit(hso_net->skb_tx_buf, hso_net->net); hso_net->skb_tx_buf = NULL; } ... } hso_net_close() runs under RTNL only, and it doesn't cancel or flush async_get_intf. Clearing HSO_NET_RUNNING before the free doesn't help against a resume that has already passed the IFF_UP check. One possible interleaving: kworker (hso_resume) ndo_stop (hso_net_close) passes flags & IFF_UP check loads hso_net->skb_tx_buf 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) dev_kfree_skb(skb) Wouldn't that read the freed skb (and send its contents in the bulk-OUT URB), and then free it a second time? The reverse order also looks possible. hso_net_start_xmit() frees the skb inside hso_resume(). Before hso_resume() sets skb_tx_buf to NULL, hso_net_close() loads the stale pointer and frees it again. hso_resume() also reads skb_tx_buf twice without READ_ONCE(). If the second read happens after close has stored NULL, hso_net_start_xmit() gets a NULL skb and dereferences skb->data. Before this patch, the same race could only leak the skb. hso_free_interface() cancels async_get_intf before the teardown free, so close looks like the main trigger. Does this free need to be serialized with hso_resume()? For example, both paths could take and clear the pointer under a lock. Another option is to flush async_get_intf and synchronize with runtime resume in ndo_stop. [Severity: Low] This isn't a bug, but dev_kfree_skb() is consume_skb(). That means drop_monitor and the skb tracepoints see this untransmitted packet as normally consumed. hso_net_start_xmit() already returned NETDEV_TX_OK for it, and net->stats.tx_dropped isn't incremented here either. Would kfree_skb() or kfree_skb_reason(), plus a tx_dropped increment, report the drop correctly? The new free in hso_free_net_device() has the same issue. [Severity: Medium] This is a pre-existing issue, but discarding the stashed skb here leaves the runtime PM reference taken for it still held. When the skb was stashed, hso_get_activity() set is_active = 1, and async_get_intf called usb_autopm_get_interface(). For the net hso_device, the only matching hso_put_activity() is in write_bulk_callback(). That runs only when a TX URB completes, and it returns early if HSO_NET_RUNNING is clear: write_bulk_callback() { ... if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { ... return; } ... hso_put_activity(odev->parent); ... } Here the skb is freed without being submitted, and hso_resume() skips the port once RUNNING is cleared. Does is_active then stay at 1, with the interface's autopm usage count still raised, so the modem can't autosuspend while the interface is down? This free would be a natural place to balance it. > + > hso_stop_net_device(odev->parent); > > /* done */ > @@ -2357,6 +2362,11 @@ static void hso_free_net_device(struct hso_device *hso_dev) > 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; [Severity: Low] Can a device that was never brought up have a stashed skb here? skb_tx_buf is only set in hso_net_start_xmit(). The stack calls that only on an up interface. hso_resume() calls it only when HSO_NET_RUNNING is set, and that bit is set in hso_net_open(). netdev_priv is zeroed at allocation, and hso_net_open() also sets skb_tx_buf to NULL. If the device was up, unregister_netdev() runs ndo_stop. So hso_net_close() has already freed and cleared the pointer before this point. Is this hunk effectively a no-op? Could the comment be reworded to match the driver's actual lifecycle? [Severity: Medium] This is a pre-existing issue, but can hso_resume() still lose the stashed skb, so that neither of the new frees sees it? hso_resume() sets skb_tx_buf to NULL unconditionally after it calls hso_net_start_xmit(). hso_get_activity() returns -EAGAIN for any state other than USB_STATE_CONFIGURED: if (hso_dev->usb->state != USB_STATE_CONFIGURED) return -EAGAIN; Suppose a disconnect marks the device NOTATTACHED while resume is in progress. hso_net_start_xmit() then stashes the same skb again: if (hso_get_activity(odev->parent) == -EAGAIN) { odev->skb_tx_buf = skb; return NETDEV_TX_OK; } hso_resume() then overwrites the only reference with NULL, and the skb leaks. Would clearing the field before the call avoid this? skb = hso_net->skb_tx_buf; hso_net->skb_tx_buf = NULL; hso_net_start_xmit(skb, hso_net->net); [Severity: Low] This is a pre-existing issue, but the hso_resume() check that guards the drain of skb_tx_buf masks the driver's flags word with a netdev flag: if (hso_net->flags & IFF_UP) { hso_net->flags holds bit indices, and the comment above HSO_NET_RUNNING says "use *_bit operations on it. (bit indices not values.)". The check works only because IFF_UP (0x1) happens to equal BIT(HSO_NET_RUNNING). Should it be test_bit(HSO_NET_RUNNING, &hso_net->flags) instead? > + > /* start freeing */ [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/6b0c372a.1800fd7e.25977e.57fb%40mx.google.com