* [PATCH v1 0/1] usbnet:fix NPE during rx_complete
@ 2025-04-01 10:18 Ying Lu
2025-04-01 10:18 ` [PATCH v1 1/1] " Ying Lu
0 siblings, 1 reply; 8+ messages in thread
From: Ying Lu @ 2025-04-01 10:18 UTC (permalink / raw)
To: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-usb, linux-kernel, luying1
From: luying1 <luying1@xiaomi.com>
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.
luying1 (1):
usbnet:fix NPE during rx_complete
drivers/net/usb/usbnet.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 1/1] usbnet:fix NPE during rx_complete
2025-04-01 10:18 [PATCH v1 0/1] usbnet:fix NPE during rx_complete Ying Lu
@ 2025-04-01 10:18 ` Ying Lu
2025-04-01 10:29 ` Greg KH
0 siblings, 1 reply; 8+ messages in thread
From: Ying Lu @ 2025-04-01 10:18 UTC (permalink / raw)
To: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-usb, linux-kernel, luying1
From: luying1 <luying1@xiaomi.com>
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).
Signed-off-by: luying1 <luying1@xiaomi.com>
---
drivers/net/usb/usbnet.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 44179f4e807f..5161bb5d824b 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -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");
--
2.40.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] usbnet:fix NPE during rx_complete
2025-04-01 10:18 ` [PATCH v1 1/1] " Ying Lu
@ 2025-04-01 10:29 ` Greg KH
2025-04-01 12:48 ` Ying Lu
0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2025-04-01 10:29 UTC (permalink / raw)
To: Ying Lu
Cc: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-usb, linux-kernel, luying1
On Tue, Apr 01, 2025 at 06:18:01PM +0800, Ying Lu wrote:
> From: luying1 <luying1@xiaomi.com>
>
> 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).
>
> Signed-off-by: luying1 <luying1@xiaomi.com>
Please use your name, not an email alias.
Also, what commit id does this fix? Should it be applied to stable
kernels?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] usbnet:fix NPE during rx_complete
2025-04-01 10:29 ` Greg KH
@ 2025-04-01 12:48 ` Ying Lu
2025-04-01 13:46 ` Greg KH
0 siblings, 1 reply; 8+ messages in thread
From: Ying Lu @ 2025-04-01 12:48 UTC (permalink / raw)
To: Greg KH
Cc: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-usb, linux-kernel, luying1
On Tue, Apr 1, 2025 at 6:31 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Tue, Apr 01, 2025 at 06:18:01PM +0800, Ying Lu wrote:
> > From: luying1 <luying1@xiaomi.com>
> >
> > 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).
> >
> > Signed-off-by: luying1 <luying1@xiaomi.com>
>
> Please use your name, not an email alias.
>
OK, I have updated. please check the Patch v2
> Also, what commit id does this fix? Should it be applied to stable
> kernels?
The commit id is 04e906839a053f092ef53f4fb2d610983412b904
(usbnet: fix cyclical race on disconnect with work queue)
Should it be applied to stable kernels? -- Yes
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] usbnet:fix NPE during rx_complete
2025-04-01 12:48 ` Ying Lu
@ 2025-04-01 13:46 ` Greg KH
2025-04-02 0:12 ` Ying Lu
0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2025-04-01 13:46 UTC (permalink / raw)
To: Ying Lu
Cc: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-usb, linux-kernel, luying1
On Tue, Apr 01, 2025 at 08:48:01PM +0800, Ying Lu wrote:
> On Tue, Apr 1, 2025 at 6:31 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Tue, Apr 01, 2025 at 06:18:01PM +0800, Ying Lu wrote:
> > > From: luying1 <luying1@xiaomi.com>
> > >
> > > 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).
> > >
> > > Signed-off-by: luying1 <luying1@xiaomi.com>
> >
> > Please use your name, not an email alias.
> >
> OK, I have updated. please check the Patch v2
>
> > Also, what commit id does this fix? Should it be applied to stable
> > kernels?
> The commit id is 04e906839a053f092ef53f4fb2d610983412b904
> (usbnet: fix cyclical race on disconnect with work queue)
> Should it be applied to stable kernels? -- Yes
Please mark the commit with that information, you seem to have not done
so for the v2 version :(
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] usbnet:fix NPE during rx_complete
2025-04-01 13:46 ` Greg KH
@ 2025-04-02 0:12 ` Ying Lu
2025-04-02 7:11 ` Greg KH
0 siblings, 1 reply; 8+ messages in thread
From: Ying Lu @ 2025-04-02 0:12 UTC (permalink / raw)
To: Greg KH
Cc: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-usb, linux-kernel, luying1
On Tue, Apr 1, 2025 at 9:48 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Tue, Apr 01, 2025 at 08:48:01PM +0800, Ying Lu wrote:
> > On Tue, Apr 1, 2025 at 6:31 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Tue, Apr 01, 2025 at 06:18:01PM +0800, Ying Lu wrote:
> > > > From: luying1 <luying1@xiaomi.com>
> > > >
> > > > 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).
> > > >
> > > > Signed-off-by: luying1 <luying1@xiaomi.com>
> > >
> > > Please use your name, not an email alias.
> > >
> > OK, I have updated. please check the Patch v2
> >
> > > Also, what commit id does this fix? Should it be applied to stable
> > > kernels?
> > The commit id is 04e906839a053f092ef53f4fb2d610983412b904
> > (usbnet: fix cyclical race on disconnect with work queue)
> > Should it be applied to stable kernels? -- Yes
>
> Please mark the commit with that information, you seem to have not done
> so for the v2 version :(
Thank you for your response. Could you please confirm if I understand correctly:
Should we include in our commit message which commit id we're fixing?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] usbnet:fix NPE during rx_complete
2025-04-02 0:12 ` Ying Lu
@ 2025-04-02 7:11 ` Greg KH
2025-04-02 8:17 ` Ying Lu
0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2025-04-02 7:11 UTC (permalink / raw)
To: Ying Lu
Cc: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-usb, linux-kernel, luying1
On Wed, Apr 02, 2025 at 08:12:06AM +0800, Ying Lu wrote:
> On Tue, Apr 1, 2025 at 9:48 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Tue, Apr 01, 2025 at 08:48:01PM +0800, Ying Lu wrote:
> > > On Tue, Apr 1, 2025 at 6:31 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> > > >
> > > > On Tue, Apr 01, 2025 at 06:18:01PM +0800, Ying Lu wrote:
> > > > > From: luying1 <luying1@xiaomi.com>
> > > > >
> > > > > 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).
> > > > >
> > > > > Signed-off-by: luying1 <luying1@xiaomi.com>
> > > >
> > > > Please use your name, not an email alias.
> > > >
> > > OK, I have updated. please check the Patch v2
> > >
> > > > Also, what commit id does this fix? Should it be applied to stable
> > > > kernels?
> > > The commit id is 04e906839a053f092ef53f4fb2d610983412b904
> > > (usbnet: fix cyclical race on disconnect with work queue)
> > > Should it be applied to stable kernels? -- Yes
> >
> > Please mark the commit with that information, you seem to have not done
> > so for the v2 version :(
> Thank you for your response. Could you please confirm if I understand correctly:
> Should we include in our commit message which commit id we're fixing?
No, use the correct "Fixes:" tag format as described in the
documentation.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] usbnet:fix NPE during rx_complete
2025-04-02 7:11 ` Greg KH
@ 2025-04-02 8:17 ` Ying Lu
0 siblings, 0 replies; 8+ messages in thread
From: Ying Lu @ 2025-04-02 8:17 UTC (permalink / raw)
To: Greg KH
Cc: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-usb, linux-kernel, luying1
On Wed, Apr 2, 2025 at 3:12 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Apr 02, 2025 at 08:12:06AM +0800, Ying Lu wrote:
> > On Tue, Apr 1, 2025 at 9:48 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Tue, Apr 01, 2025 at 08:48:01PM +0800, Ying Lu wrote:
> > > > On Tue, Apr 1, 2025 at 6:31 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> > > > >
> > > > > On Tue, Apr 01, 2025 at 06:18:01PM +0800, Ying Lu wrote:
> > > > > > From: luying1 <luying1@xiaomi.com>
> > > > > >
> > > > > > 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).
> > > > > >
> > > > > > Signed-off-by: luying1 <luying1@xiaomi.com>
> > > > >
> > > > > Please use your name, not an email alias.
> > > > >
> > > > OK, I have updated. please check the Patch v2
> > > >
> > > > > Also, what commit id does this fix? Should it be applied to stable
> > > > > kernels?
> > > > The commit id is 04e906839a053f092ef53f4fb2d610983412b904
> > > > (usbnet: fix cyclical race on disconnect with work queue)
> > > > Should it be applied to stable kernels? -- Yes
> > >
> > > Please mark the commit with that information, you seem to have not done
> > > so for the v2 version :(
> > Thank you for your response. Could you please confirm if I understand correctly:
> > Should we include in our commit message which commit id we're fixing?
>
> No, use the correct "Fixes:" tag format as described in the
> documentation.
>
> thanks,
>
> greg k-h
Oh, I see. Thank you very much for the reminder!
I've already fixed it in the PATCH v3. Could you please take another look?
Thanks,
Ying Lu
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-04-02 8:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 10:18 [PATCH v1 0/1] usbnet:fix NPE during rx_complete Ying Lu
2025-04-01 10:18 ` [PATCH v1 1/1] " Ying Lu
2025-04-01 10:29 ` Greg KH
2025-04-01 12:48 ` Ying Lu
2025-04-01 13:46 ` Greg KH
2025-04-02 0:12 ` Ying Lu
2025-04-02 7:11 ` Greg KH
2025-04-02 8:17 ` Ying Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).