KCSAN: data-race in __dev_open / is_ndev_for_default_gid_filter (2)

Status: moderation: reported on 2026/11/17 16:20
Subsystems: rdma
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+36fe1befce434db57b22@syzkaller.appspotmail.com
First crash: 14h53m, last: 6h43m
✨ AI cause bisection: introduced by (AI job) :
commit 464b79b45aede2859eb46ae91786f0266868602b
Author: Parav Pandit <parav@mellanox.com>
Date: Tue Aug 14 07:36:19 2018 +0000

  IB/core: Add default GIDs of the bond master netdev

  
✨ AI-generated root cause summary:

A data race occurs on the 4-byte struct net_device::flags field between __dev_open() and is_ndev_for_default_gid_filter(). While bringing an interface up via rtnetlink, __dev_open() calls netif_set_up() under the RTNL lock to set the IFF_UP bit using plain read-modify-write operations without WRITE_ONCE annotations. Concurrently, asynchronous InfiniBand RoCE GID cache processing on gid_cache_wq invokes is_ndev_for_default_gid_filter(), which calls netif_is_bond_master() under RCU read lock and performs an unannotated read of dev->flags to check IFF_MASTER without READ_ONCE(). Because struct net_device::flags can be inspected locklessly under RCU while being updated under RTNL, the lack of READ_ONCE/WRITE_ONCE access markings triggers a KCSAN data-race report.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 666539eecdf4:

Root Cause Analysis

1. Racing Field and Memory Location

The reported KCSAN data race occurs at offset 0xb0 (176 bytes, or 1408 bits) within struct net_device, which corresponds to the 4-byte field:

2. Writer Call Trace (Task 3295)

A userspace task configuring an interface via rtnetlink calls:

rtnl_newlink()
  -> __rtnl_newlink()
  -> rtnl_changelink()
  -> do_setlink()
  -> netif_change_flags()
  -> __dev_change_flags()
  -> __dev_open()
  -> netif_set_up(dev, true)
  • In __dev_open() (net/core/dev.c:1769), ASSERT_RTNL() ensures the RTNL lock is held.
  • In netif_set_up() (net/core/dev.h:200):
    static inline void netif_set_up(struct net_device *dev, bool value)
    {
        if (value)
            dev->flags |= IFF_UP;
        else
            dev->flags &= ~IFF_UP;
        ...
    }
    
    netif_set_up() performs a plain C read-modify-write operation (dev->flags |= IFF_UP) without WRITE_ONCE() annotations. (Similarly, __dev_change_flags() at net/core/dev.c:9996 performs plain stores to dev->flags).

3. Reader Call Trace (Task 345)

Netdevice state change events invoke the InfiniBand RoCE notifier:

netdevice_event()
  -> netdevice_queue_work()
     [dispatches work to gid_cache_wq via INIT_WORK(&ndev_work->work, netdevice_event_work_handler)]

Asynchronously on the workqueue thread:

worker_thread()
  -> process_scheduled_works()
  -> netdevice_event_work_handler()
  -> ib_enum_all_roce_netdevs()
  -> ib_enum_roce_netdev()
  -> is_ndev_for_default_gid_filter()
  -> netif_is_bond_master()
  • In is_ndev_for_default_gid_filter() (drivers/infiniband/core/roce_gid_mgmt.c:201), execution is protected by rcu_read_lock() rather than rtnl_lock().
  • It calls netif_is_bond_master(cookie_ndev) (include/linux/netdevice.h:5613):
    static inline bool netif_is_bond_master(const struct net_device *dev)
    {
        return dev->flags & IFF_MASTER && dev->priv_flags & IFF_BONDING;
    }
    
    This performs a plain 4-byte read of cookie_ndev->flags without READ_ONCE(). (The same pattern exists in netif_is_bond_slave() at line 5618 for dev->flags & IFF_SLAVE).

4. Mechanism and Invariant Violation

While writers of dev->flags are serialized with respect to one another by the RTNL lock, several reader pathsβ€”including RoCE GID management under rcu_read_lock()β€”read dev->flags locklessly.

Because netif_is_bond_master() (and netif_is_bond_slave()) in include/linux/netdevice.h access dev->flags without READ_ONCE(), and netif_set_up() in net/core/dev.h (as well as __dev_change_flags() in net/core/dev.c) modifies dev->flags without WRITE_ONCE() or atomic bit operations, KCSAN detects an unannotated concurrent read and write to the same 32-bit memory location.

▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
7d7cef16 assessment-kcsan Benign: βœ… ❓ KCSAN: data-race in __dev_open / is_ndev_for_default_gid_filter (2) 2026/11/17 15:59 2026/11/17 15:59 2026/11/17 16:54 ca622473
d5179e24 bisect-cause ❓ KCSAN: data-race in __dev_open / is_ndev_for_default_gid_filter (2) 2026/11/17 15:54 2026/11/17 15:54 2026/11/17 16:42 ca622473
be169b33 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: βœ… VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in __dev_open / is_ndev_for_default_gid_filter (2) 2026/11/17 15:52 2026/11/17 15:52 2026/11/17 16:13 ca622473
▶ ▼ Similar bugs (1)
Kernel Title Rank πŸ›ˆ Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KCSAN: data-race in __dev_open / is_ndev_for_default_gid_filter net 6 1 2111d 2111d 0/29 auto-closed as invalid on 2021/03/12 06:46

Sample crash report:
veth1_vlan: entered promiscuous mode
==================================================================
BUG: KCSAN: data-race in __dev_open / is_ndev_for_default_gid_filter

read to 0xffff88811a4050b0 of 4 bytes by task 345 on cpu 0:
 netif_is_bond_master include/linux/netdevice.h:5615 [inline]
 is_ndev_for_default_gid_filter+0x35/0x120 drivers/infiniband/core/roce_gid_mgmt.c:220
 ib_enum_roce_netdev+0x119/0x1e0 drivers/infiniband/core/device.c:2574
 ib_enum_all_roce_netdevs+0x89/0x100 drivers/infiniband/core/device.c:2601
 netdevice_event_work_handler+0x9a/0x1f0 drivers/infiniband/core/roce_gid_mgmt.c:648
 process_one_work kernel/workqueue.c:3495 [inline]
 process_scheduled_works+0x582/0xab0 kernel/workqueue.c:3578
 worker_thread+0x56c/0x770 kernel/workqueue.c:3659
 kthread+0x248/0x2a0 kernel/kthread.c:436
 ret_from_fork+0x146/0x330 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

read-write to 0xffff88811a4050b0 of 4 bytes by task 3295 on cpu 0:
 netif_set_up net/core/dev.h:-1 [inline]
 __dev_open+0x370/0x590 net/core/dev.c:1769
 __dev_change_flags+0x1c8/0x490 net/core/dev.c:10022
 netif_change_flags+0x53/0xc0 net/core/dev.c:10087
 do_setlink+0x92d/0x2950 net/core/rtnetlink.c:3294
 rtnl_changelink net/core/rtnetlink.c:3942 [inline]
 __rtnl_newlink net/core/rtnetlink.c:4113 [inline]
 rtnl_newlink+0x1187/0x1550 net/core/rtnetlink.c:4252
 rtnetlink_rcv_msg+0x64b/0x720 net/core/rtnetlink.c:7169
 netlink_rcv_skb+0x11e/0x220 net/netlink/af_netlink.c:2585
 rtnetlink_rcv+0x1c/0x30 net/core/rtnetlink.c:7196
 netlink_unicast_kernel net/netlink/af_netlink.c:1336 [inline]
 netlink_unicast+0x6fd/0x7e0 net/netlink/af_netlink.c:1362
 netlink_sendmsg+0x605/0x760 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:800 [inline]
 __sock_sendmsg net/socket.c:818 [inline]
 __sys_sendto+0x429/0x480 net/socket.c:2283
 __do_sys_sendto net/socket.c:2290 [inline]
 __se_sys_sendto net/socket.c:2286 [inline]
 __x64_sys_sendto+0x76/0x90 net/socket.c:2286
 x64_sys_call+0x200c/0x2550 arch/x86/include/generated/asm/syscalls_64.h:45
 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: 0 UID: 0 PID: 3295 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================
veth0_macvtap: entered promiscuous mode
veth1_macvtap: entered promiscuous mode
batman_adv: batadv0: Interface activated: batadv_slave_0
batman_adv: batadv0: Interface activated: batadv_slave_1

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 10:17 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __dev_open / is_ndev_for_default_gid_filter
2026/11/17 02:07 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __dev_open / is_ndev_for_default_gid_filter
* Struck through repros no longer work on HEAD.