linux/net/ipv6
Kuniyuki Iwashima 4c6fbb1fba ipv6: Protect multiple routes insertion by table lock.
syzbot reported the warning below. [0]

While call_fib6_multipath_entry_notifiers() is called locklessly,
fib6_siblings could be changed concurrently, leading to the
warning (and later null-ptr-deref).

Let's protect multiple routes insertion with tb6_lock.

Along with that, __ip6_ins_rt() and ip6_route_del() are changed
to fib6_add() and fib6_del().

Note that fib6_del() finally calls rt6_multipath_rebalance(),
which requires rcu_read_lock().

[0]:
i != fen6_info->nsiblings
WARNING: drivers/net/netdevsim/fib.c:831 at nsim_fib6_event_init drivers/net/netdevsim/fib.c:831 [inline], CPU#0: syz.0.157/6279
WARNING: drivers/net/netdevsim/fib.c:831 at nsim_fib6_prepare_event drivers/net/netdevsim/fib.c:947 [inline], CPU#0: syz.0.157/6279
WARNING: drivers/net/netdevsim/fib.c:831 at nsim_fib_event_schedule_work drivers/net/netdevsim/fib.c:1003 [inline], CPU#0: syz.0.157/6279
WARNING: drivers/net/netdevsim/fib.c:831 at nsim_fib_event_nb+0x1029/0x11d0 drivers/net/netdevsim/fib.c:1043, CPU#0: syz.0.157/6279
Modules linked in:
CPU: 0 UID: 0 PID: 6279 Comm: syz.0.157 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
RIP: 0010:nsim_fib6_event_init drivers/net/netdevsim/fib.c:831 [inline]
RIP: 0010:nsim_fib6_prepare_event drivers/net/netdevsim/fib.c:947 [inline]
RIP: 0010:nsim_fib_event_schedule_work drivers/net/netdevsim/fib.c:1003 [inline]
RIP: 0010:nsim_fib_event_nb+0x1029/0x11d0 drivers/net/netdevsim/fib.c:1043
Code: eb 0d 4d 89 fd e8 b7 c5 6c fa be 01 00 00 00 48 89 df e8 5a 38 85 fd 4d 89 ef 4c 8b 6c 24 20 e9 4a f3 ff ff e8 98 c5 6c fa 90 <0f> 0b 90 e9 db fa ff ff 89 e9 80 e1 07 80 c1 03 38 c1 0f 8c df f0
RSP: 0018:ffffc900047bef10 EFLAGS: 00010293
RAX: ffffffff875b59a8 RBX: 0000000000000002 RCX: ffff888079770000
RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000001
RBP: ffffc900047bf0a0 R08: ffff88805c0bb02f R09: 1ffff1100b817605
R10: dffffc0000000000 R11: ffffed100b817606 R12: dffffc0000000000
R13: 0000000000000000 R14: 0000000000000001 R15: ffff88802c792000
FS:  00007f334ba076c0(0000) GS:ffff888123ad0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f334ba06ff8 CR3: 000000007a5b2000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 notifier_call_chain+0x1a5/0x3d0 kernel/notifier.c:85
 atomic_notifier_call_chain+0xda/0x180 kernel/notifier.c:223
 call_fib_notifiers+0x31/0x60 net/core/fib_notifier.c:36
 call_fib6_multipath_entry_notifiers+0xf5/0x160 net/ipv6/ip6_fib.c:428
 ip6_route_multipath_add net/ipv6/route.c:5542 [inline]
 inet6_rtm_newroute+0x14f5/0x1a30 net/ipv6/route.c:5664
 rtnetlink_rcv_msg+0x802/0xc00 net/core/rtnetlink.c:7163
 netlink_rcv_skb+0x226/0x4a0 net/netlink/af_netlink.c:2572
 netlink_unicast_kernel net/netlink/af_netlink.c:1335 [inline]
 netlink_unicast+0x7bd/0x940 net/netlink/af_netlink.c:1361
 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1916
 sock_sendmsg_nosec+0x14e/0x190 net/socket.c:800
 __sock_sendmsg net/socket.c:818 [inline]
 ____sys_sendmsg+0x54e/0x850 net/socket.c:2715
 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2769
 __sys_sendmmsg+0x273/0x4d0 net/socket.c:2858
 __do_sys_sendmmsg net/socket.c:2885 [inline]
 __se_sys_sendmmsg net/socket.c:2882 [inline]
 __x64_sys_sendmmsg+0xa0/0xc0 net/socket.c:2882
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f334ab9e1d9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f334ba07028 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00007f334ae26090 RCX: 00007f334ab9e1d9
RDX: 04000000000001f2 RSI: 0000200000000000 RDI: 0000000000000004
RBP: 00007f334ac35888 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000000000fc R11: 0000000000000246 R12: 0000000000000000
R13: 00007f334ae26128 R14: 00007f334ae26090 R15: 00007ffd96688aa8
 </TASK>

Fixes: 169fd62799 ("ipv6: Get rid of RTNL for SIOCADDRT and RTM_NEWROUTE.")
Reported-by: syzbot+751b587577d0ebca10f2@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/6adbaed6.67317f00.38c4bc.001b.GAE@google.com/T/
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20261027065247.2871134-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-28 17:23:50 -07:00
..
ila ila: reload IPv6 header after pskb_may_pull in checksum adjust 2026-07-22 14:00:41 -07:00
netfilter netfilter: nf_reject: initialize IPCB at inet ingress 2026-10-19 14:12:26 +02:00
addrconf_core.c ipv6: remove obsolete EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL() 2026-06-05 17:47:42 -07:00
addrconf.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-10-22 11:45:58 +02:00
addrlabel.c
af_inet6.c net: Order blackhole_netdev_init(), inet_init(), and inet6_init(). 2026-10-06 15:56:15 -07:00
ah6.c net: ipv6: fix typos in comments 2026-09-07 17:59:00 -07:00
anycast.c ipv6: anycast: insert aca into global hash under idev->lock 2026-06-02 19:30:39 -07:00
calipso.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-10-22 11:45:58 +02:00
datagram.c net: Replace %pK output with 0 2026-09-02 18:38:16 -07:00
esp6_offload.c
esp6.c net: skbuff: replace skb_page_unref() and __skb_frag_unref() with skb_netmem_unref() 2026-10-20 11:52:46 +02:00
exthdrs_core.c ipv6: do not let ipv6_find_hdr() return an offset past the packet end 2026-09-18 16:53:22 -07:00
exthdrs_offload.c
exthdrs.c seg6: fix HMAC validation when an extension header precedes the SRH 2026-10-01 12:58:27 +02:00
fib6_notifier.c
fib6_rules.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-07-30 12:53:19 -07:00
fou6.c udp: Support BIG TCP GSO packets where they can occur 2026-07-22 13:47:02 +02:00
icmp.c net: Const qualify ctl_tables that kmemdup unconditionally 2026-08-13 13:12:24 +02:00
inet6_connection_sock.c tcp: rehash onto different local ECMP path on retransmit timeout 2026-06-15 15:57:31 -07:00
inet6_hashtables.c
ioam6_iptunnel.c ipv6: ioam: fix type confusion of dst_entry 2026-06-21 15:26:40 -07:00
ioam6.c net: ioam6: no longer acquire qdisc spinlock while calling qdisc_qstats_qlen_backlog() 2026-05-14 17:05:20 -07:00
ip6_checksum.c
ip6_fib.c ipv6: Protect multiple routes insertion by table lock. 2026-10-28 17:23:50 -07:00
ip6_flowlabel.c ipv6: flowlabel: cap duplicate leases per socket 2026-09-07 21:24:05 -07:00
ip6_gre.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-10-22 11:45:58 +02:00
ip6_icmp.c
ip6_input.c ip: orphan prefetched skbs before multicast forwarding 2026-08-18 13:05:14 +02:00
ip6_offload.c net: gso: limit recursive IP-in-IP segmentation 2026-09-29 12:02:37 +02:00
ip6_offload.h
ip6_output.c ipv6: Use ipv6_neigh_lookup() and friends. 2026-10-07 16:07:03 -07:00
ip6_tunnel.c netfilter: flowtable: add encap_proto to flow_offload_tunnel 2026-10-18 02:41:38 +02:00
ip6_udp_tunnel.c udp: Set length in UDP header to 0 for big GSO packets 2026-07-22 13:47:02 +02:00
ip6_vti.c net: ipv6: fix typos in comments 2026-09-07 17:59:00 -07:00
ip6mr.c ipmr: drop packets with unknown ingress VIF 2026-10-26 16:41:28 -07:00
ipcomp6.c xfrm: add extack to xfrm_init_state 2026-06-04 12:22:35 +02:00
ipv6_sockglue.c ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT setsockopt lockless 2026-09-17 15:25:18 +02:00
Kconfig
Makefile ipv6: ndisc: Add ndisc_check_ns_na() validation helper 2026-08-07 16:32:46 -07:00
mcast_snoop.c
mcast.c ipv6: mcast: use jiffies_delta_to_clock_t() in igmp6_mc_seq_show() 2026-08-31 17:54:46 -07:00
mip6.c
ndisc_snoop.c ipv6: ndisc: Add ndisc_check_ns_na() validation helper 2026-08-07 16:32:46 -07:00
ndisc.c ipv6: Use ipv6_neigh_lookup() and friends. 2026-10-07 16:07:03 -07:00
netfilter.c netfilter: bridge: fix stale prevhdr pointer in br_ip6_fragment() 2026-07-10 16:28:47 +02:00
output_core.c ipv6: remove obsolete EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL() 2026-06-05 17:47:42 -07:00
ping.c
proc.c
protocol.c
raw.c ipv6: raw: convert do_rawv6_getsockopt to sockopt_t 2026-08-03 16:55:22 -07:00
reassembly.c inet: frags: prevent acceptance of partially authenticated reassembly 2026-10-28 09:19:07 +00:00
route.c ipv6: Protect multiple routes insertion by table lock. 2026-10-28 17:23:50 -07:00
rpl_iptunnel.c
rpl.c
seg6_hmac.c seg6: fix HMAC validation when an extension header precedes the SRH 2026-10-01 12:58:27 +02:00
seg6_iptunnel.c net: ipv6: seg6: report lwtunnel setup errors via extack 2026-10-15 12:29:16 +02:00
seg6_local.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-10-01 11:02:44 -07:00
seg6.c ipv6: sr: enforce exact attribute length for SEG6_ATTR_DST 2026-09-23 18:34:13 -07:00
sit.c sit: do not report an error from ipip6_fill_info() 2026-09-14 19:04:37 -07:00
syncookies.c tcp: rehash onto different local ECMP path on retransmit timeout 2026-06-15 15:57:31 -07:00
sysctl_net_ipv6.c net: Const qualify ctl_tables that kmemdup unconditionally 2026-08-13 13:12:24 +02:00
tcp_ao.c
tcp_ipv6.c net: psp: require an established connection for association setup 2026-10-05 15:59:46 -07:00
tcpv6_offload.c net: gro: Fix nesting of TCP GSO SKBs in skb_gro_receive_list() 2026-09-03 12:20:38 +02:00
tunnel6.c
udp_offload.c udp: Support gro_ipv4_max_size > 65536 2026-07-22 13:47:02 +02:00
udp.c ipv6: udp: Use ip6_sk_redirect() for tunnel sockets 2026-09-08 14:48:00 +02:00
xfrm6_input.c xfrm6: fix out-of-bounds write in xfrm6_input_addr() when secpath is full 2026-07-13 09:30:18 +02:00
xfrm6_output.c ipv6: xfrm: use full sockets in local error paths 2026-08-18 12:16:18 +02:00
xfrm6_policy.c net: Const qualify network templated ctl_tables Arrays 2026-08-13 13:12:24 +02:00
xfrm6_protocol.c
xfrm6_state.c
xfrm6_tunnel.c