๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20273

Re: [PATCH v2 net-next 1/1] net: usb: rtl8150: break cycle between tasklet and URB

#20273
From: netdev-bot+sashiko
Date: Sat, 21 Nov 2026 23:02
236 lines
16581 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 1 (1) ยท Medium: 1 (1) ยท Low: 0

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] Poisoning the URBs does not break the cycle.
- [Medium] The tasklet/URB resubmission cycle from the commit message is
  still open in rtl8150_close() and rtl8150_suspend().

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
  read_bulk_callback() hands dev->rx_skb to netif_rx() (line 430).
- [Medium] This problem wasn't introduced by this patch, but rx_fixup()
  has a second self-rescheduling path that never touches a URB.

--

net: usb: rtl8150: break cycle between tasklet and URB

In rtl8150_disconnect(), this patch swaps usb_kill_urb() for
usb_poison_urb() on all three URBs. The goal is to stop the rx_fixup()
tasklet from resubmitting rx_urb. It also adds a second tasklet_kill()
after poisoning, so the tasklet is stopped before the URBs and skbs are
freed.

> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> index d51e43170e033..6d20f52d52efd 100644
> --- a/drivers/net/usb/rtl8150.c
> +++ b/drivers/net/usb/rtl8150.c
> @@ -353,6 +353,13 @@ static void free_all_urbs(rtl8150_t * dev)
>  	usb_free_urb(dev->intr_urb);
>  }
>  
> +static void terminate_all_urbs(rtl8150_t *dev)
> +{
> +	usb_poison_urb(dev->rx_urb);
> +	usb_poison_urb(dev->tx_urb);
> +	usb_poison_urb(dev->intr_urb);
> +}
> +
>  static void unlink_all_urbs(rtl8150_t * dev)
>  {
>  	usb_kill_urb(dev->rx_urb);

[Severity: Medium]
The commit message says the tasklet/URB cycle needs to be broken. Is it
still open in rtl8150_close() and rtl8150_suspend()? Both stop rx_urb
with usb_kill_urb() only, and neither one stops the tasklet:

rtl8150_close() {
    ...
	if (!test_bit(RTL8150_UNPLUG, &dev->flags))
		disable_net_traffic(dev);
	unlink_all_urbs(dev);
    ...
}

usb_kill_urb() raises urb->reject only while the call is running. If
rx_fixup() is pending or looping when close runs, its submit fails with
-EPERM during the kill and it reschedules itself. The next run, after
usb_kill_urb() has returned, then submits rx_urb successfully:

rx_fixup() {
    ...
try_again:
	status = usb_submit_urb(dev->rx_urb, GFP_ATOMIC);
    ...
}

The tasklet can easily be pending at close time. read_bulk_callback()
schedules it whenever the 4-entry rx_skb_pool runs dry, and it keeps
looping while GFP_ATOMIC allocation fails.

disable_net_traffic() has already turned the receiver off, so the
bulk-IN URB just stays in flight. On the next ndo_open, rtl8150_open()
refills and resubmits the URB that is still active:

	usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
		      dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev);
	if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) {

That would hit the "URB %p submitted while active" WARN_ONCE in
usb_submit_urb() and return -EBUSY. Wouldn't every later open then fail
the same way until the device is replugged or rebound?

The suspend path looks similar. A tasklet submit can follow the
usb_kill_urb() in rtl8150_suspend(), and a later resubmit of rx_urb
after resume would then fail with -EBUSY.

[ ... ]

> @@ -970,7 +977,8 @@ static void rtl8150_disconnect(struct usb_interface *intf)
>  		set_bit(RTL8150_UNPLUG, &dev->flags);
>  		tasklet_kill(&dev->tl);
>  		unregister_netdev(dev->netdev);
> -		unlink_all_urbs(dev);
> +		terminate_all_urbs(dev);
> +		tasklet_kill(&dev->tl);

[Severity: High]
Does poisoning actually break the cycle here? It makes every resubmit
fail. However, rx_fixup() reschedules itself after any submit error
other than -ENODEV, and it never checks RTL8150_UNPLUG:

rx_fixup() {
    ...
	if (test_bit(RX_URB_FAIL, &dev->flags))
		if (dev->rx_skb)
			goto try_again;
    ...
try_again:
	status = usb_submit_urb(dev->rx_urb, GFP_ATOMIC);
	if (status == -ENODEV) {
		netif_device_detach(dev->netdev);
	} else if (status) {
		set_bit(RX_URB_FAIL, &dev->flags);
		goto tlsched;
    ...
}

On a soft unbind (rmmod, sysfs unbind, or a forced unbind from
usb_reset_device()), the device is still attached, so usb_submit_urb()
never returns -ENODEV. Instead:

- rtl8150_driver has no soft_unbind, so usb_unbind_interface() disables
  the endpoints before calling ->disconnect. Submits then fail with
  -ENOENT from usb_hcd_link_urb_to_ep().
- After terminate_all_urbs(), urb->reject stays raised for good, so
  submits fail with -EPERM.

Either way, once the tasklet runs it reschedules itself forever.

tasklet_action_common() clears TASKLET_STATE_SCHED just before it calls
the callback, and the callback sets it again. tasklet_kill() waits with
wait_on_bit_lock(SCHED) in TASK_UNINTERRUPTIBLE, so it can only win
inside that short window.

On a non-RT kernel, a waiter on the same CPU cannot preempt the softirq,
so it only ever sees SCHED set. On UP, wouldn't this be a deterministic
livelock? rtl8150_disconnect() would sit in D state holding the device
lock while ksoftirqd spins. On SMP the waiter can keep losing the race.

The loop can also start before this point. On a soft unbind with the
interface up, usb_disable_interface() flushes rx_urb with -ESHUTDOWN
while RTL8150_UNPLUG is still clear. read_bulk_callback() takes the
default case to goon, the resubmit fails with -ENOENT, and it calls
tasklet_schedule(). So the existing first tasklet_kill() already faces
this loop, and on a soft unbind the new second one always faces it.

Could rx_fixup() be stopped from rescheduling instead? For example, it
could check RTL8150_UNPLUG on entry or treat -EPERM/-ENOENT as fatal.
Another option is to disable the tasklet before killing it.

[Severity: Medium]
This isn't a bug introduced by this patch, but rx_fixup() has a second
self-rescheduling path that never touches a URB:

rx_fixup() {
    ...
	spin_lock_irq(&dev->rx_pool_lock);
	skb = pull_skb(dev);
	spin_unlock_irq(&dev->rx_pool_lock);
	if (skb == NULL)
		goto tlsched;
    ...
}

If dev_alloc_skb(RTL8150_MTU + 2) in fill_skb_pool() fails while the
pool is empty, pull_skb() returns NULL and the tasklet reschedules
itself. Poisoning in terminate_all_urbs() has no effect on this path,
and RTL8150_UNPLUG is not checked.

While GFP_ATOMIC allocations keep failing at disconnect time, can both
tasklet_kill() calls in rtl8150_disconnect() stall the same way as
described above? The stall ends once an allocation succeeds, so it only
lasts as long as the memory pressure. A check for RTL8150_UNPLUG at the
top of rx_fixup() would fix this along with the issue above.

>  		free_all_urbs(dev);
>  		free_skb_pool(dev);
>  		dev_kfree_skb(dev->rx_skb);

[Severity: High]
This is a pre-existing issue, but can dev->rx_skb be stale here?
read_bulk_callback() hands dev->rx_skb to the stack. When the pool is
empty, it leaves the old pointer in place:

read_bulk_callback() {
    ...
	netif_rx(dev->rx_skb);
    ...
	spin_lock_irqsave(&dev->rx_pool_lock, flags);
	skb = pull_skb(dev);
	spin_unlock_irqrestore(&dev->rx_pool_lock, flags);
	if (!skb)
		goto resched;

	dev->rx_skb = skb;
    ...
}

The pool has only 4 entries and only the tasklet refills it, so this
happens routinely. Nothing ever sets dev->rx_skb to NULL. The pointer
is only replaced by a later successful pull_skb() in rx_fixup().

If that replacement never happens, this dev_kfree_skb() frees an skb
that the network stack already owns. It can fail to happen in two ways:

- dev_alloc_skb() in rx_fixup() fails on the run during which
  tasklet_kill() wins.
- A completion passes the RTL8150_UNPLUG check just before set_bit().
  Its tasklet_schedule() then runs while the first tasklet_kill() holds
  TASKLET_STATE_SCHED through wait_on_bit_lock(). tasklet_schedule()
  does nothing when SCHED is already set, so the tasklet never runs.

The same stale pointer also seems to affect rtl8150_open():

	if (dev->rx_skb == NULL)
		dev->rx_skb = pull_skb(dev);

Suppose a close/open happens while the tasklet is still looping on
allocation failure. Wouldn't rx_urb then be submitted with the freed
skb's data as its DMA buffer?

Because of this, the "if (!dev->rx_skb) goto resched;" check in
read_bulk_callback() also looks like dead code.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118133550.955312-1-oneukum%40suse.com
Technical Details
Message-ID: <179530217871.3135.15339133875090021236@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368505-linux-kernel-netdev=dewy.ru
References: <20261118133550.955312-1-oneukum@suse.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368505-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v2 net-next 1/1] net: usb: rtl8150: break cycle between tasklet and URB
Date: Sat, 21 Nov 2026 23:02:58 +0000
Organization: Usenet Network
Message-ID: <179530217871.3135.15339133875090021236@kernel.org>
References: <20261118133550.955312-1-oneukum@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="3516704"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:zQa+/8khjc0duc/TtoHqJSfmU4E= sha256:1N6+eBYs5VHTolGqIhPkLsmgLM9GIQcNuqd79DJ8wyc= sha1:HBYzmaPxUs4gjxwfK5LyhXBGP/w= sha256:bb8huP0FlzQ5Qh4BVJAn7DRx9mMpUXYz02AIOGNb/As=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id A2318115C24; Sun, 22 Nov 2026 02:03:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.3
X-Spam-Status: No, score=-2.3 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tk3ReYESsu_R; Sun, 22 Nov 2026 02:03:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368505-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 8EAE0115C20; Sun, 22 Nov 2026 02:03:41 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 482B9328FA; Sat, 21 Nov 2026 23:03:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795302185; b=l/ZsjHwARxXDk2gBgtmSRBbF/NhKXmGgtnm3+tWBn8/RmQwFwHdlivTFxZAd1OwP2G/C z716dXy7XCh4BsQ9ACUYZlNjLj1Nv5FsO8iwvpA3GmxlGCmGiN8ijZ27H0x7fx87s2hxx Cpsm3ZHRe5IUBTnoUsh1ZgxDa+g5yl02cdI1iutVFI2krEO6KeIGZIrPVLrfYvoWOO1vI ozra7sd1jT0QH852oIIFyCUfxfS549T3NHFNvTQwGA9dapRe2BTHmv1O5eGmOVaeYOzA7 OedjnRAHq7mYWUgr9k9yNMGe52d2NhoK2p+nC7v5beWsQL+KnOPtqkT76bbXRZVkwhw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795302185; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=vi6Jgwc6TTLYkbHGmqEuP1xt7X0Hvny/9CR4U2gZGgY=; b=JsS3cIAjtaijWbthsT/1a15XFgD5qUs428nfSLOzA4rL7qb1zqeuZK9y0LF0VKivVJ1u 2lzQGpkYIME+n4KUhep2e75/JJD2dOYfqSkImIZNhmd7xANdbonRAoP9kj9hwaLizqiG5 ZT3htIN3s9aGfevH5tf85G0cwhVFlyvHNnWJcoAbdCUmGrfNS43UtZkKPHMaCg4mRR+QD GcoMsXyTjV5SgatXl9HOoZuPGwApss870WLtrtyDVkRFlxRehYhhi4vB7ufmitzBBy+Ln blFOpKFeCg2t3FhckeXCK5OeycyI44/ZgXIecOlctnqiVQaE3qqPmbk7biAXZXgH5rg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YYLLdz9o; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2E3C606A696; Sat, 21 Nov 2026 23:03:05 +0000 (UTC)
X-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=YYLLdz9o
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795302180; b=AGHGTRX/YVdAigE07dXM8ie3yGW5GiQAM0nkly3UEcn0/pcG0TYOLEHHpcupuPhghSZw SWHgkm+Y+z+k2jTgunodjbN2FQPJxp/qPrDhrLf57KLQRej79i+26XyZwgXYJVhbhPAqP EhCA+ps6XTHe25d26p1LiQohFkwg/D2X3iFd/8XhKuwxUvUntzu2zJKjSgIHugdko8xUX u8Ud/b3oK/wrDDN4m9soWKqFuv2cpUewq//uXpCUrZNtS2hix70O6+zrFhCVP9wrdcED4 RcVwTLG+mn/YbknYoDCBrMoeE8SSvTEv5JKhifHcI14NxP5y9aXI4nWeJgywgCn3S4Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795302180; 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=vi6Jgwc6TTLYkbHGmqEuP1xt7X0Hvny/9CR4U2gZGgY=; b=xbqrS7BYB/FwprffOjm0Rk1X6PGsNUaCMMPfymUIxhx6NTecGaUhgQhNUrpy8ZJlTPWg EuBGKGlDbmmu5wb5Z1d/ZV+9y19xNZBvVSCjOR/KGsw+XXakZ8oYLXRO1MfgnRctAT2W7 U782fhaOzaBoqXt2GCF02JaA/JH2OOaAKJtgnNUbEJJFbcuinlTd8zEdi5GKXR9ySO3VT dlwiYs3UNjlx9fYtk6u44aNQQrXJUCApmGzZNjKeox1LkzTlk98r/eefb6sjjCYh1FaoP fR9OeGmgSwLOLyIlfPeWhfhjVMIvizRU2Y/skFhu4wn5b5NCez6a3nwWXhJ3rGC9Rhw==
X-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=YYLLdz9o; arc=none smtp.remote-ip=100.103.45.18
X-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 E35DD606A33F; Sat, 21 Nov 2026 23:02:59 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27B971F000E6; Sat, 21 Nov 2026 23:02:59 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795302179; bh=vi6Jgwc6TTLYkbHGmqEuP1xt7X0Hvny/9CR4U2gZGgY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=YYLLdz9osX2szQUNhd6zJ/6b9f6Tc7ycsLvdyYdL4B0Qi3bvBSsWXiBRkgCPmxXwg J07ix74tCN1Co2Z3/9IMJo/0sDnF9WvagXPN6E7jJuih6J34gFzzGgZ0GlJ84RNhse Fw/RJCIL6u6yz3KK+dLFBlCPz0Iy5pQTbxMawk4b+iVHWQGTjxI3af0eu524sEcde0 Uz4ktTRygnLZ/DRGBvPAlwvJvfYJ+PfJ+Zx+pClRkmAS8B2XZTawY6Tlk5AV3EXIrk XqJZRzkDXiwKHghs9uuSRH+cVWa6PUMfvFVHpviJ5v9OWGsSEHNUaf2zMrImxdlDlC 0BlZ1rLQiaZhg==
X-Cc: petkan@nucleusys.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org
X-In-Reply-To: <20261118133550.955312-1-oneukum@suse.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 16322