net: bridge: fix nd_tbl NULL dereference when IPv6 is disabled
Subsystems (3)
PATCH v3 1/2 net: bridge: fix nd_tbl NULL dereference when IPv6 is disabled
When booting with the 'ipv6.disable=1' parameter, the nd_tbl is never initialized because inet6_init() exits before ndisc_init() is called which initializes it. Then, if neigh_suppress is enabled and an ICMPv6 Neighbor Discovery packet reaches the bridge, br_do_suppress_nd() will dereference ipv6_stub->nd_tbl which is NULL, passing it to neigh_lookup(). This causes a kernel NULL pointer dereference.
BUG: kernel NULL pointer dereference, address: 0000000000000268 Oops: 0000 [#1] PREEMPT SMP NOPTI [...] RIP: 0010:neigh_lookup+0x16/0xe0 [...] Call Trace: <IRQ> ? neigh_lookup+0x16/0xe0 br_do_suppress_nd+0x160/0x290 [bridge] br_handle_frame_finish+0x500/0x620 [bridge] br_handle_frame+0x353/0x440 [bridge] __netif_receive_skb_core.constprop.0+0x298/0x1110 __netif_receive_skb_one_core+0x3d/0xa0 process_backlog+0xa0/0x140 __napi_poll+0x2c/0x170 net_rx_action+0x2c4/0x3a0 handle_softirqs+0xd0/0x270 do_softirq+0x3f/0x60
Fix this by replacing IS_ENABLED(IPV6) call with ipv6_mod_enabled() in the callers. This is in essence disabling NS/NA suppression when IPv6 is disabled.
---
v2: use ipv6_mod_enabled() instead of a null check and replace the check on the caller
v3: no changes
--- net/bridge/br_device.c | 2 +- net/bridge/br_input.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/bridge/br_device.c +1 -1
@@ -74,7 +74,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) eth_hdr(skb)->h_proto == htons(ETH_P_RARP)) && br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED)) {br_do_proxy_suppress_arp (skb, br, vid,NULL ); - } else if (IS_ENABLED(CONFIG_IPV6) && + } else if (ipv6_mod_enabled() && skb->protocol == htons(ETH_P_IPV6) && br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED) && pskb_may_pull(skb, sizeof(struct ipv6hdr) +
net/bridge/br_input.c +1 -1
@@ -170,7 +170,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb (skb->protocol == htons(ETH_P_ARP) || skb->protocol == htons(ETH_P_RARP))) {br_do_proxy_suppress_arp (skb, br, vid, p); - } else if (IS_ENABLED(CONFIG_IPV6) && + } else if (ipv6_mod_enabled() && skb->protocol == htons(ETH_P_IPV6) && br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED) && pskb_may_pull(skb, sizeof(struct ipv6hdr) +
Signature · 1 line
2.53.0
PATCH v3 2/2 net: vxlan: fix nd_tbl NULL dereference when IPv6 is disabled
When booting with the 'ipv6.disable=1' parameter, the nd_tbl is never initialized because inet6_init() exits before ndisc_init() is called which initializes it. If an IPv6 packet is injected into the interface, route_shortcircuit() is called and a NULL pointer dereference happens on neigh_lookup().
BUG: kernel NULL pointer dereference, address: 0000000000000380 Oops: Oops: 0000 [#1] SMP NOPTI [...] RIP: 0010:neigh_lookup+0x20/0x270 [...] Call Trace: <TASK> vxlan_xmit+0x638/0x1ef0 [vxlan] dev_hard_start_xmit+0x9e/0x2e0 __dev_queue_xmit+0xbee/0x14e0 packet_sendmsg+0x116f/0x1930 __sys_sendto+0x1f5/0x200 __x64_sys_sendto+0x24/0x30 do_syscall_64+0x12f/0x1590 entry_SYSCALL_64_after_hwframe+0x76/0x7e
Fix this by adding an early check on route_shortcircuit() when protocol is ETH_P_IPV6. Note that ipv6_mod_enabled() cannot be used here because VXLAN can be built-in even when IPv6 is built as a module.
---
v2: use ipv6_mod_enabled() instead of a NULL check
v3: go back to nd_tbl NULL check as ipv6_mod_enabled() might not be available. Added a comment so it doesn't seem random.
--- drivers/net/vxlan/vxlan_core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/vxlan/vxlan_core.c +5 -0
@@ -2130,6 +2130,11 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb) {struct ipv6hdr *pip6; +/* check if nd_tbl is not initiliazed due to +* ipv6.disable=1 set during boot +*/ +if (!ipv6_stub->nd_tbl) +return false;if (!pskb_may_pull (skb,sizeof (struct ipv6hdr )))return false; pip6 =ipv6_hdr (skb);
Signature · 1 line
2.53.0
Quoted 26 lines · Fernando Fernandez Mancera
When booting with the 'ipv6.disable=1' parameter, the
nd_tblis never initialized becauseinet6_init()exits beforendisc_init()is called which initializes it. Then, ifneigh_suppressis enabled and an ICMPv6 Neighbor Discovery packet reaches the bridge,br_do_suppress_nd()will dereferenceipv6_stub->nd_tblwhich is NULL, passing it toneigh_lookup(). This causes a kernel NULL pointer dereference.BUG: kernel NULL pointer dereference, address: 0000000000000268 Oops: 0000 [#1] PREEMPT SMP NOPTI [...] RIP: 0010:neigh_lookup+0x16/0xe0 [...] Call Trace: <IRQ> ? neigh_lookup+0x16/0xe0 br_do_suppress_nd+0x160/0x290 [bridge] br_handle_frame_finish+0x500/0x620 [bridge] br_handle_frame+0x353/0x440 [bridge] __netif_receive_skb_core.constprop.0+0x298/0x1110 __netif_receive_skb_one_core+0x3d/0xa0 process_backlog+0xa0/0x140 __napi_poll+0x2c/0x170 net_rx_action+0x2c4/0x3a0 handle_softirqs+0xd0/0x270 do_softirq+0x3f/0x60
Quoted 8 lines
Fix this by replacing
IS_ENABLED(IPV6)call withipv6_mod_enabled()in the callers. This is in essence disabling NS/NA suppression when IPv6 is disabled.Fixes ed842faeb2bd ("bridge: suppress nd pkts on BR_NEIGH_SUPPRESS ports")Reported-by Guruprasad C P <[email protected]>Closes https://lore.kernel.org/netdev/CAHXs0ORzd62QOG-Fttqa2Cx_A_VFp=utE2H2VTX5nqfgs7LDxQ@mail.gmail.com/ open hereSigned-off-by Fernando Fernandez Mancera <[email protected]>
I assume you will remove ipv6_stub from the bridge in net-next
Quoted 31 lines · Ido Schimmel
Quoted 30 lines · Fernando Fernandez Mancera
When booting with the 'ipv6.disable=1' parameter, the
nd_tblis never initialized becauseinet6_init()exits beforendisc_init()is called which initializes it. Then, ifneigh_suppressis enabled and an ICMPv6 Neighbor Discovery packet reaches the bridge,br_do_suppress_nd()will dereferenceipv6_stub->nd_tblwhich is NULL, passing it toneigh_lookup(). This causes a kernel NULL pointer dereference.BUG: kernel NULL pointer dereference, address: 0000000000000268 Oops: 0000 [#1] PREEMPT SMP NOPTI [...] RIP: 0010:neigh_lookup+0x16/0xe0 [...] Call Trace: <IRQ> ? neigh_lookup+0x16/0xe0 br_do_suppress_nd+0x160/0x290 [bridge] br_handle_frame_finish+0x500/0x620 [bridge] br_handle_frame+0x353/0x440 [bridge] __netif_receive_skb_core.constprop.0+0x298/0x1110 __netif_receive_skb_one_core+0x3d/0xa0 process_backlog+0xa0/0x140 __napi_poll+0x2c/0x170 net_rx_action+0x2c4/0x3a0 handle_softirqs+0xd0/0x270 do_softirq+0x3f/0x60Fix this by replacing
IS_ENABLED(IPV6)call withipv6_mod_enabled()in the callers. This is in essence disabling NS/NA suppression when IPv6 is disabled.
Quoted 8 lines
Quoted 4 lines
Fixes ed842faeb2bd ("bridge: suppress nd pkts on BR_NEIGH_SUPPRESS ports")Reported-by Guruprasad C P <[email protected]>Closes https://lore.kernel.org/netdev/CAHXs0ORzd62QOG-Fttqa2Cx_A_VFp=utE2H2VTX5nqfgs7LDxQ@mail.gmail.com/ open hereSigned-off-by Fernando Fernandez Mancera <[email protected]>Reviewed-by Ido Schimmel <[email protected]>I assume you will remove
ipv6_stubfrom the bridge in net-next
Yes, a patch series dropping ipv6_stub is cooking.
Quoted 34 lines · Fernando Fernandez Mancera
When booting with the 'ipv6.disable=1' parameter, the
nd_tblis never initialized becauseinet6_init()exits beforendisc_init()is called which initializes it. Then, ifneigh_suppressis enabled and an ICMPv6 Neighbor Discovery packet reaches the bridge,br_do_suppress_nd()will dereferenceipv6_stub->nd_tblwhich is NULL, passing it toneigh_lookup(). This causes a kernel NULL pointer dereference.BUG: kernel NULL pointer dereference, address: 0000000000000268 Oops: 0000 [#1] PREEMPT SMP NOPTI [...] RIP: 0010:neigh_lookup+0x16/0xe0 [...] Call Trace: <IRQ> ? neigh_lookup+0x16/0xe0 br_do_suppress_nd+0x160/0x290 [bridge] br_handle_frame_finish+0x500/0x620 [bridge] br_handle_frame+0x353/0x440 [bridge] __netif_receive_skb_core.constprop.0+0x298/0x1110 __netif_receive_skb_one_core+0x3d/0xa0 process_backlog+0xa0/0x140 __napi_poll+0x2c/0x170 net_rx_action+0x2c4/0x3a0 handle_softirqs+0xd0/0x270 do_softirq+0x3f/0x60Fix this by replacing
IS_ENABLED(IPV6)call withipv6_mod_enabled()in the callers. This is in essence disabling NS/NA suppression when IPv6 is disabled.Fixes ed842faeb2bd ("bridge: suppress nd pkts on BR_NEIGH_SUPPRESS ports")Reported-by Guruprasad C P <[email protected]>Closes https://lore.kernel.org/netdev/CAHXs0ORzd62QOG-Fttqa2Cx_A_VFp=utE2H2VTX5nqfgs7LDxQ@mail.gmail.com/ open hereSigned-off-by Fernando Fernandez Mancera <[email protected]>
Quoted 5 lines
---
v2: useipv6_mod_enabled()instead of a null check and replace the check on the caller
v3: no changes
---
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Wed, 4 Mar 2026 13:03:56 +0100 you wrote:
When booting with the 'ipv6.disable=1' parameter, the
nd_tblis never initialized becauseinet6_init()exits beforendisc_init()is called which initializes it. Then, ifneigh_suppressis enabled and an ICMPv6 Neighbor Discovery packet reaches the bridge,br_do_suppress_nd()will dereferenceipv6_stub->nd_tblwhich is NULL, passing it toneigh_lookup(). This causes a kernel NULL pointer dereference.[...]
Here is the summary with links:
- [1/2,net,v3] net: bridge: fix nd_tbl NULL dereference when IPv6 is disabled
https://git.kernel.org/netdev/net/c/e5e890630533 - [2/2,net,v3] net: vxlan: fix nd_tbl NULL dereference when IPv6 is disabled https://git.kernel.org/netdev/net/c/168ff39e4758
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html