* [PATCH 1/2] usbnet: fix smp_processor_id() use in preemptible context
@ 2026-09-03 16:46 Ömer Mete Kaya
0 siblings, 0 replies; only message in thread
From: Ömer Mete Kaya @ 2026-09-03 16:46 UTC (permalink / raw)
To: netdev
Cc: oneukum, andrew+netdev, davem, edumazet, kuba, pabeni, linux-usb,
linux-kernel, Ömer Mete Kaya, syzbot+04cd90bb99c6ef81a65d
usbnet_skb_return() and tx_complete() call this_cpu_ptr() before
disabling IRQs, which triggers a BUG when running with PREEMPT_FULL:
BUG: using smp_processor_id() in preemptible code in tx_complete
Fix by saving IRQs first with local_irq_save(), then calling
this_cpu_ptr() and using the non-irqsave variants of u64_stats
update helpers, since IRQs are already disabled at that point.
Reported-by: syzbot+04cd90bb99c6ef81a65d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=04cd90bb99c6ef81a65d
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
drivers/net/usb/usbnet.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index a19ecf718f36..6a48f38e105d 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -325,7 +325,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev)
*/
void usbnet_skb_return(struct usbnet *dev, struct sk_buff *skb)
{
- struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->net->tstats);
+ struct pcpu_sw_netstats *stats64;
unsigned long flags;
int status;
@@ -338,10 +338,13 @@ void usbnet_skb_return(struct usbnet *dev, struct sk_buff *skb)
if (skb->protocol == 0)
skb->protocol = eth_type_trans(skb, dev->net);
- flags = u64_stats_update_begin_irqsave(&stats64->syncp);
+ local_irq_save(flags);
+ stats64 = this_cpu_ptr(dev->net->tstats);
+ u64_stats_update_begin(&stats64->syncp);
u64_stats_inc(&stats64->rx_packets);
u64_stats_add(&stats64->rx_bytes, skb->len);
- u64_stats_update_end_irqrestore(&stats64->syncp, flags);
+ u64_stats_update_end(&stats64->syncp);
+ local_irq_restore(flags);
netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n",
skb->len + sizeof(struct ethhdr), skb->protocol);
@@ -1298,13 +1301,16 @@ static void tx_complete(struct urb *urb)
struct usbnet *dev = entry->dev;
if (urb->status == 0) {
- struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->net->tstats);
+ struct pcpu_sw_netstats *stats64;
unsigned long flags;
- flags = u64_stats_update_begin_irqsave(&stats64->syncp);
+ local_irq_save(flags);
+ stats64 = this_cpu_ptr(dev->net->tstats);
+ u64_stats_update_begin(&stats64->syncp);
u64_stats_add(&stats64->tx_packets, entry->packets);
u64_stats_add(&stats64->tx_bytes, entry->length);
- u64_stats_update_end_irqrestore(&stats64->syncp, flags);
+ u64_stats_update_end(&stats64->syncp);
+ local_irq_restore(flags);
} else {
dev->net->stats.tx_errors++;
--
2.55.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-03 16:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 16:46 [PATCH 1/2] usbnet: fix smp_processor_id() use in preemptible context Ömer Mete Kaya
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox