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 adding a check before br_is_local_ip6() or neigh_lookup()
call. If ipv6_stub->nd_tbl is NULL, return immediately.

Fixes: ed842faeb2bd ("bridge: suppress nd pkts on BR_NEIGH_SUPPRESS ports")
Closes: 
https://lore.kernel.org/netdev/CAHXs0ORzd62QOG-Fttqa2Cx_A_VFp=ute2h2vtx5nqfgs7l...@mail.gmail.com/
Signed-off-by: Fernando Fernandez Mancera <[email protected]>
---
Note: I am investigating more places where this might be happening too.
---
 net/bridge/br_arp_nd_proxy.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/bridge/br_arp_nd_proxy.c b/net/bridge/br_arp_nd_proxy.c
index 1e2b51769eec..ed756518cee0 100644
--- a/net/bridge/br_arp_nd_proxy.c
+++ b/net/bridge/br_arp_nd_proxy.c
@@ -437,6 +437,12 @@ void br_do_suppress_nd(struct sk_buff *skb, struct 
net_bridge *br,
                return;
        }
 
+       /* IPv6 disabled at boot, return before calling into br_is_local_ip6()
+        * or neigh_lookup()
+        */
+       if (!ipv6_stub->nd_tbl)
+               return;
+
        if (vid != 0) {
                /* build neigh table lookup on the vlan device */
                vlandev = __vlan_find_dev_deep_rcu(br->dev, skb->vlan_proto,
-- 
2.53.0


Reply via email to