Skip to contentSkip to conversation

veth: manage XDP program pointers during channel resize

PATCH Applied Jakub Kicinski 5 participants 5 messages Sep 21 – Sep 24

Subsystems (2)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH v2 1/1 veth: manage XDP program pointers during channel resize

veth_set_channels() tears down XDP resources for removed RX queues without clearing rq->xdp_prog. If the program is then detached or replaced, those queues keep the old pointer after bpf_prog_put(). A later channel increase can re-enable NAPI and run the freed program.

  BUG: unable to handle page fault for address: ffffc90000256048
  Oops: Oops: 0000 [#1] SMP KASAN NOPTI
  RIP: veth_xdp_rcv_skb (include/linux/filter.h:779
                         include/net/xdp.h:696 drivers/net/veth.c:820)
  Call Trace:
   veth_xdp_rcv (drivers/net/veth.c:941)
   veth_poll (drivers/net/veth.c:986)
   __napi_poll (net/core/dev.c:7787)
   net_rx_action (net/core/dev.c:7850 net/core/dev.c:8007)
   handle_softirqs (kernel/softirq.c:645)
  Kernel panic - not syncing: Fatal exception in interrupt
Fixes 4752eeb3d891 ("veth: implement support for set_channel ethtool op")

---
v2:
- different placement to avoid extra loops
v1: https://lore.kernel.org/[email protected]

---
 drivers/net/veth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/veth.c +2 -0
index 6ed3ee81153f..71227d0389aa 100644
@@ -1054,6 +1054,7 @@ static int __veth_napi_enable_range(struct net_device *dev, int start, int end)
 	for (i = start; i < end; i++) {
 		struct veth_rq *rq = &priv->rq[i];
 
+		rcu_assign_pointer(rq->xdp_prog, priv->_xdp_prog);
 		napi_enable(&rq->xdp_napi);
 		rcu_assign_pointer(priv->rq[i].napi, &priv->rq[i].xdp_napi);
 	}
@@ -1088,6 +1089,7 @@ static void veth_napi_del_range(struct net_device *dev, int start, int end)
 
 		rcu_assign_pointer(priv->rq[i].napi, NULL);
 		napi_disable(&rq->xdp_napi);
+		rcu_assign_pointer(rq->xdp_prog, NULL);
 		__netif_napi_del(&rq->xdp_napi);
 	}
 	synchronize_net();
Signature · 1 line
2.55.0
Acked-by on v2 1/1
#1 lore raw
Quoted 17 lines · Jakub Kicinski

veth_set_channels() tears down XDP resources for removed RX queues without clearing rq->xdp_prog. If the program is then detached or replaced, those queues keep the old pointer after bpf_prog_put(). A later channel increase can re-enable NAPI and run the freed program.

  BUG: unable to handle page fault for address: ffffc90000256048
  Oops: Oops: 0000 [#1] SMP KASAN NOPTI
  RIP: veth_xdp_rcv_skb (include/linux/filter.h:779
                         include/net/xdp.h:696 drivers/net/veth.c:820)
  Call Trace:
   veth_xdp_rcv (drivers/net/veth.c:941)
   veth_poll (drivers/net/veth.c:986)
   __napi_poll (net/core/dev.c:7787)
   net_rx_action (net/core/dev.c:7850 net/core/dev.c:8007)
   handle_softirqs (kernel/softirq.c:645)
  Kernel panic - not syncing: Fatal exception in interrupt
Quoted 3 lines
Fixes 4752eeb3d891 ("veth: implement support for set_channel ethtool op")
Reviewed-by on v2 1/1
#2 lore raw
In reply to Jakub Kicinski
Quoted 41 lines · Jakub Kicinski

veth_set_channels() tears down XDP resources for removed RX queues without clearing rq->xdp_prog. If the program is then detached or replaced, those queues keep the old pointer after bpf_prog_put(). A later channel increase can re-enable NAPI and run the freed program.

   BUG: unable to handle page fault for address: ffffc90000256048
   Oops: Oops: 0000 [#1] SMP KASAN NOPTI
   RIP: veth_xdp_rcv_skb (include/linux/filter.h:779
                          include/net/xdp.h:696 drivers/net/veth.c:820)
   Call Trace:
    veth_xdp_rcv (drivers/net/veth.c:941)
    veth_poll (drivers/net/veth.c:986)
    __napi_poll (net/core/dev.c:7787)
    net_rx_action (net/core/dev.c:7850 net/core/dev.c:8007)
    handle_softirqs (kernel/softirq.c:645)
   Kernel panic - not syncing: Fatal exception in interrupt
Fixes 4752eeb3d891 ("veth: implement support for set_channel ethtool op")

---
v2:
- different placement to avoid extra loops
v1: https://lore.kernel.org/[email protected]

---
  drivers/net/veth.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/net/veth.c +1 -0
index 6ed3ee81153f..71227d0389aa 100644
@@ -1054,6 +1054,7 @@ static int __veth_napi_enable_range(struct net_device *dev, int start, int end)
  	for (i = start; i < end; i++) {
  		struct veth_rq *rq = &priv->rq[i];
 
+		rcu_assign_pointer(rq->xdp_prog, priv->_xdp_prog);
  		napi_enable(&rq->xdp_napi);
  		rcu_assign_pointer(priv->rq[i].napi, &priv->rq[i].xdp_napi);
  	}

drivers/net/veth.c static void veth_napi_del_range(struct net_device *dev, int start, int end) · line 1095

Quoted 7 lines
drivers/net/veth.c +1 -0
@@ -1088,6 +1089,7 @@ static void veth_napi_del_range(struct net_device *dev, int start, int end)
 
  		rcu_assign_pointer(priv->rq[i].napi, NULL);
  		napi_disable(&rq->xdp_napi);
+		rcu_assign_pointer(rq->xdp_prog, NULL);
  		__netif_napi_del(&rq->xdp_napi);
  	}
  	synchronize_net();
Reviewed-by on v2 1/1
#3 lore raw
In reply to Jakub Kicinski
Quoted 18 lines · Jakub Kicinski

veth_set_channels() tears down XDP resources for removed RX queues without clearing rq->xdp_prog. If the program is then detached or replaced, those queues keep the old pointer after bpf_prog_put(). A later channel increase can re-enable NAPI and run the freed program.

  BUG: unable to handle page fault for address: ffffc90000256048
  Oops: Oops: 0000 [#1] SMP KASAN NOPTI
  RIP: veth_xdp_rcv_skb (include/linux/filter.h:779
                         include/net/xdp.h:696 drivers/net/veth.c:820)
  Call Trace:
   veth_xdp_rcv (drivers/net/veth.c:941)
   veth_poll (drivers/net/veth.c:986)
   __napi_poll (net/core/dev.c:7787)
   net_rx_action (net/core/dev.c:7850 net/core/dev.c:8007)
   handle_softirqs (kernel/softirq.c:645)
  Kernel panic - not syncing: Fatal exception in interrupt
Quoted 3 lines
Fixes 4752eeb3d891 ("veth: implement support for set_channel ethtool op")
#4 lore raw
In reply to Jakub Kicinski
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 17 lines · On Mon, 21 Sep 2026 16:18:56 -0700 you wrote:

veth_set_channels() tears down XDP resources for removed RX queues without clearing rq->xdp_prog. If the program is then detached or replaced, those queues keep the old pointer after bpf_prog_put(). A later channel increase can re-enable NAPI and run the freed program.

  BUG: unable to handle page fault for address: ffffc90000256048
  Oops: Oops: 0000 [#1] SMP KASAN NOPTI
  RIP: veth_xdp_rcv_skb (include/linux/filter.h:779
                         include/net/xdp.h:696 drivers/net/veth.c:820)
  Call Trace:
   veth_xdp_rcv (drivers/net/veth.c:941)
   veth_poll (drivers/net/veth.c:986)
   __napi_poll (net/core/dev.c:7787)
   net_rx_action (net/core/dev.c:7850 net/core/dev.c:8007)
   handle_softirqs (kernel/softirq.c:645)
  Kernel panic - not syncing: Fatal exception in interrupt
Quoted 1 line

[...]

Here is the summary with links:
- [net,v2] veth: manage XDP program pointers during channel resize

    https://git.kernel.org/netdev/net/c/7104a3707143

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html