usbnet:fix NPE during rx_complete
Subsystems (6)
v4 cover usbnet:fix NPE during rx_complete
From: Ying Lu <[email protected]>
The patchset fix the issue caused by the following modifications:
commit 04e906839a053f092ef53f4fb2d610983412b904 (usbnet: fix cyclical race on disconnect with work queue)
The issue:
The usb_submit_urb function lacks a usbnet_going_away validation, whereas __usbnet_queue_skb includes this check. This inconsistency creates a race condition where: A URB request may succeed, but the corresponding SKB data fails to be queued.
Subsequent processes (e.g., rx_complete → defer_bh → __skb_unlink(skb, list)) attempt to access skb->next, triggering a NULL pointer dereference (Kernel Panic).
Fix issue:
adding the usbnet_going_away check in usb_submit_urb to synchronize the validation logic.
Changes in v4
-use the correct "Cc:" tag format.
Changes in v3
-use the correct "Fixes:" tag format.
Changes in v2
-Use the formal name instead of an email alias.
Ying Lu (1):
usbnet:fix NPE during rx_complete
drivers/net/usb/usbnet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.49.0
PATCH v4 1/1 usbnet:fix NPE during rx_complete
From: Ying Lu <[email protected]>
Missing usbnet_going_away Check in Critical Path. The usb_submit_urb function lacks a usbnet_going_away validation, whereas __usbnet_queue_skb includes this check.
This inconsistency creates a race condition where:
A URB request may succeed, but the corresponding SKB data fails to be queued.
Subsequent processes:
(e.g., rx_complete → defer_bh → __skb_unlink(skb, list)) attempt to access skb->next, triggering a NULL pointer dereference (Kernel Panic).
--- drivers/net/usb/usbnet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/usbnet.c +3 -3
@@ -519,7 +519,8 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)netif_device_present (dev->net) &&test_bit (EVENT_DEV_OPEN , &dev->flags) && !test_bit (EVENT_RX_HALT , &dev->flags) && - !test_bit (EVENT_DEV_ASLEEP, &dev->flags)) { + !test_bit (EVENT_DEV_ASLEEP , &dev->flags) && + !usbnet_going_away(dev)) { switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) {case -EPIPE :usbnet_defer_kevent (dev,EVENT_RX_HALT );
@@ -540,8 +541,7 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)tasklet_schedule (&dev->bh);break ;case 0 : -if (!usbnet_going_away (dev)) -__usbnet_queue_skb (&dev->rxq, skb, rx_start); +__usbnet_queue_skb (&dev->rxq, skb, rx_start); } }else {netif_dbg (dev, ifdown, dev->net,"rx: stopped\n" );
Signature · 1 line
2.49.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Wed, 2 Apr 2025 16:58:58 +0800 you wrote:
From: Ying Lu <[email protected]>
The patchset fix the issue caused by the following modifications:
commit04e906839a053f092ef53f4fb2d610983412b904(usbnet: fix cyclical race on disconnect with work queue)
Quoted 7 lines
The issue:
Theusb_submit_urbfunction lacks ausbnet_going_awayvalidation, whereas__usbnet_queue_skbincludes this check. This inconsistency creates a race condition where: A URB request may succeed, but the corresponding SKB data fails to be queued.[...]
Here is the summary with links:
- [v4,1/1] usbnet:fix NPE during rx_complete
https://git.kernel.org/netdev/net/c/51de36000934
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html