KCSAN: data-race in fib_table_flush / fib_table_lookup

Status: moderation: reported on 2026/11/19 00:01
Subsystems: net
Labels: race:benign prio:low
[Documentation on labels]
Reported-by: syzbot+0a8054531338de22fdbc@syzkaller.appspotmail.com
First crash: 1d17h, last: 21h24m
✨ AI cause bisection: introduced by (AI job) :
commit 5405afd1a30620de8601436bae739c67c0bc7324
Author: Alexander Duyck <alexander.h.duyck@redhat.com>
Date: Wed Dec 31 18:57:08 2014 +0000

  fib_trie: Add tracking value for suffix length

  
✨ AI-generated root cause summary:

In net/ipv4/fib_trie.c, struct key_vector::slen tracks the maximum suffix length of prefixes stored under a tnode or leaf. Lockless readers executing fib_table_lookup() under rcu_read_lock() perform unannotated plain loads of n->slen (e.g. lines 1478 and 1497) without READ_ONCE(), while concurrent writers executing fib_table_flush() under RTNL invoke update_suffix() which writes tn->slen in-place (line 737) without WRITE_ONCE(). This unsynchronized concurrent read/write access constitutes a data race detected by KCSAN.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 63fdb511c27a:

Root Cause Analysis

1. Involved Functions, Structs, and Files

2. Technical Mechanism & Invariant Violation

  • In the LPC-trie implementation (net/ipv4/fib_trie.c), struct key_vector::slen denotes the maximum suffix length (KEYLENGTH - plen) found among all prefixes present in a node or in its subtree.
  • In fib_table_lookup(), readers traverse the trie locklessly without acquiring RTNL. Readers inspect n->slen with plain, unannotated reads:
    • Step 1 (line 1478): if (n->slen > n->pos) decides whether to remember the parent node pn and index cindex for backtracking when searching for shorter prefix matches.
    • Step 2 (line 1497): if (unlikely(prefix_mismatch(key, n)) || (n->slen == n->pos)) checks whether prefix mismatches occur or whether there are no remaining shorter prefixes that necessitate further backtracing.
  • Concurrently, when routes associated with a netdevice are flushed (e.g., via fib_table_flush() during device unregistration), the writer traverses the trie under RTNL, removes dead route aliases with hlist_del_rcu(), and calls update_suffix(pn) at line 2035 to recalculate and update the suffix lengths of parent nodes to account for removed child routes.
  • update_suffix() performs an in-place plain store to the live node:
    tn->slen = slen;
    
    at line 737.
  • Because tn->slen is updated in-place without WRITE_ONCE() while lockless RCU readers inspect n->slen without READ_ONCE(), concurrent execution on multiple CPUs triggers a KCSAN data race report between fib_table_flush and fib_table_lookup.
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
2445b70b bisect-cause ❓ KCSAN: data-race in fib_table_flush / fib_table_lookup 2026/11/18 09:20 2026/11/18 09:20 2026/11/18 09:31 eb4895d7
0595cf29 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in fib_table_flush / fib_table_lookup 2026/11/18 07:58 2026/11/18 07:58 2026/11/18 08:36 eb4895d7
9c5bfd71 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in fib_table_flush / fib_table_lookup 2026/11/18 07:37 2026/11/18 07:37 2026/11/18 08:17 eb4895d7

Sample crash report:
==================================================================
BUG: KCSAN: data-race in fib_table_flush / fib_table_lookup

read to 0xffff888103ad1726 of 1 bytes by task 3280 on cpu 0:
 fib_table_lookup+0x12a/0xe00 net/ipv4/fib_trie.c:1478
 fib_lookup include/net/ip_fib.h:391 [inline]
 ip_route_output_key_hash_rcu+0x337/0x1360 net/ipv4/route.c:2861
 ip_route_output_key_hash net/ipv4/route.c:2752 [inline]
 __ip_route_output_key include/net/route.h:175 [inline]
 ip_route_output_flow+0x65/0x110 net/ipv4/route.c:2979
 __ip_queue_xmit+0x495/0xc30 net/ipv4/ip_output.c:495
 ip_queue_xmit+0x39/0x50 net/ipv4/ip_output.c:547
 __tcp_transmit_skb+0x1cad/0x2110 net/ipv4/tcp_output.c:1773
 tcp_transmit_skb net/ipv4/tcp_output.c:1790 [inline]
 tcp_write_xmit+0x13b5/0x30e0 net/ipv4/tcp_output.c:3126
 tcp_push_one+0x7e/0xa0 net/ipv4/tcp_output.c:3323
 tcp_sendmsg_locked+0x1e7e/0x2df0 net/ipv4/tcp.c:1408
 tcp_sendmsg+0x2f/0x50 net/ipv4/tcp.c:1465
 inet_sendmsg+0x76/0xd0 net/ipv4/af_inet.c:866
 sock_sendmsg_nosec net/socket.c:801 [inline]
 __sock_sendmsg net/socket.c:818 [inline]
 sock_write_iter+0x2a5/0x300 net/socket.c:1269
 new_sync_write fs/read_write.c:575 [inline]
 vfs_write+0x57a/0x9b0 fs/read_write.c:667
 ksys_write+0xdc/0x1a0 fs/read_write.c:719
 __do_sys_write fs/read_write.c:730 [inline]
 __se_sys_write fs/read_write.c:727 [inline]
 __x64_sys_write+0x40/0x50 fs/read_write.c:727
 x64_sys_call+0x154e/0x2550 arch/x86/include/generated/asm/syscalls_64.h:2
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

write to 0xffff888103ad1726 of 1 bytes by task 6380 on cpu 1:
 update_suffix net/ipv4/fib_trie.c:737 [inline]
 fib_table_flush+0x2d4/0x990 net/ipv4/fib_trie.c:2035
 fib_flush net/ipv4/fib_frontend.c:216 [inline]
 fib_disable_ip net/ipv4/fib_frontend.c:1469 [inline]
 fib_netdev_event+0x268/0x440 net/ipv4/fib_frontend.c:1538
 notifier_call_chain+0x90/0x200 kernel/notifier.c:86
 raw_notifier_call_chain+0x2d/0x40 kernel/notifier.c:558
 call_netdevice_notifiers_info net/core/dev.c:2313 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2351 [inline]
 call_netdevice_notifiers net/core/dev.c:2365 [inline]
 netif_close_many+0x288/0x3a0 net/core/dev.c:1867
 netif_close_many_and_unlock net/core/dev.c:12658 [inline]
 unregister_netdevice_many_notify+0x353/0x15e0 net/core/dev.c:12733
 unregister_netdevice_many net/core/dev.c:12841 [inline]
 unregister_netdevice_queue+0x1cd/0x200 net/core/dev.c:12637
 unregister_netdevice include/linux/netdevice.h:3511 [inline]
 nsim_destroy+0x162/0x5d0 drivers/net/netdevsim/netdev.c:1206
 __nsim_dev_port_del+0xd2/0x140 drivers/net/netdevsim/dev.c:1471
 nsim_dev_port_del_all drivers/net/netdevsim/dev.c:1485 [inline]
 nsim_dev_reload_destroy+0x1a1/0x2c0 drivers/net/netdevsim/dev.c:1709
 nsim_drv_remove+0x3e/0x110 drivers/net/netdevsim/dev.c:1724
 nsim_bus_remove+0x15/0x20 drivers/net/netdevsim/bus.c:426
 device_remove drivers/base/dd.c:617 [inline]
 __device_release_driver drivers/base/dd.c:1357 [inline]
 device_release_driver_internal+0x2bb/0x510 drivers/base/dd.c:1380
 device_release_driver+0x19/0x20 drivers/base/dd.c:1403
 bus_remove_device+0x2fa/0x320 drivers/base/bus.c:678
 device_del+0x35f/0x790 drivers/base/core.c:3967
 device_unregister+0x15/0x40 drivers/base/core.c:4008
 nsim_bus_dev_del drivers/net/netdevsim/bus.c:488 [inline]
 del_device_store+0x1c1/0x220 drivers/net/netdevsim/bus.c:243
 bus_attr_store+0x57/0x80 drivers/base/bus.c:172
 sysfs_kf_write+0xfe/0x120 fs/sysfs/file.c:145
 kernfs_fop_write_iter+0x1d2/0x2e0 fs/kernfs/file.c:345
 new_sync_write fs/read_write.c:575 [inline]
 vfs_write+0x57a/0x9b0 fs/read_write.c:667
 ksys_write+0xdc/0x1a0 fs/read_write.c:719
 __do_sys_write fs/read_write.c:730 [inline]
 __se_sys_write fs/read_write.c:727 [inline]
 __x64_sys_write+0x40/0x50 fs/read_write.c:727
 x64_sys_call+0x154e/0x2550 arch/x86/include/generated/asm/syscalls_64.h:2
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 6380 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/18 03:19 upstream 63fdb511c27a 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in fib_table_flush / fib_table_lookup
2026/11/17 18:47 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in fib_table_flush / fib_table_lookup
2026/11/17 07:04 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in fib_table_flush / fib_table_lookup
2026/11/17 07:03 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in fib_table_flush / fib_table_lookup
2026/11/17 07:02 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in fib_table_flush / fib_table_lookup
2026/11/17 07:01 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in fib_table_flush / fib_table_lookup
* Struck through repros no longer work on HEAD.