KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter (5)

Status: moderation: reported on 2026/11/19 00:02
Subsystems: rdma
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+7c6b452f20b74f8baa85@syzkaller.appspotmail.com
First crash: 1d16h, last: 2h56m
✨ AI-generated root cause summary:

A data race occurs on net_device::flags between __dev_change_flags() updating interface flags under RTNL lock and netif_is_bond_master() reading dev->flags locklessly (under RCU) from is_ndev_for_default_gid_filter() in the RoCE GID management workqueue. __dev_change_flags() writes to dev->flags via a plain assignment without WRITE_ONCE(), unlike other flag mutators such as __dev_set_promiscuity() and netif_set_allmulti(). Simultaneously, netif_is_bond_master() (and netif_is_bond_slave()) inspects dev->flags using a plain read without READ_ONCE(), triggering a KCSAN data race warning.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 4405c18c95d2:

Root Cause Analysis

1. Functions, Structs, and Fields Involved


2. Technical Mechanism and Trigger Condition

  1. Concurrent Writers and Readers on dev->flags:

    • In net/core/dev.c:9996, __dev_change_flags() updates the net device flags:
      dev->flags = (flags & (IFF_DEBUG | IFF_NOTRAILERS | IFF_NOARP |
                             IFF_DYNAMIC | IFF_MULTICAST | IFF_PORTSEL |
                             IFF_AUTOMEDIA)) |
                   (dev->flags & (IFF_UP | IFF_VOLATILE | IFF_PROMISC |
                                  IFF_ALLMULTI));
      
      This function executes while holding the RTNL lock (netdev_assert_locked_ops_compat(dev)). Unlike sibling functions modifying dev->flags (such as __dev_set_promiscuity() line 9881 and netif_set_allmulti() line 9940, which use WRITE_ONCE(dev->flags, flags)), __dev_change_flags() performs a direct, unmarked read-modify-write assignment on dev->flags.
  2. Lockless Reader Path:

    • Network device event notifications in the InfiniBand/RoCE subsystem enqueue asynchronous work (netdevice_queue_work()) onto the gid-cache-wq workqueue.
    • The worker function netdevice_event_work_handler() processes these events without holding the RTNL lock. Instead, it holds an active reference (dev_hold()) and runs under rcu_read_lock() while iterating devices:
      static bool is_ndev_for_default_gid_filter(struct ib_device *ib_dev, u32 port,
                                                 struct net_device *rdma_ndev,
                                                 void *cookie)
      {
          ...
          rcu_read_lock();
          res = ((cookie_ndev == rdma_ndev && !netif_is_bond_slave(rdma_ndev)) ||
                 (netif_is_bond_master(cookie_ndev) &&
                  rdma_is_upper_dev_rcu(rdma_ndev, cookie_ndev)));
          rcu_read_unlock();
          return res;
      }
      
    • netif_is_bond_master() (and netif_is_bond_slave()) in include/linux/netdevice.h:
      static inline bool netif_is_bond_master(const struct net_device *dev)
      {
          return dev->flags & IFF_MASTER && dev->priv_flags & IFF_BONDING;
      }
      
      performs a plain read of dev->flags & IFF_MASTER without using READ_ONCE(). Notice that other reader helpers like netif_get_flags() and netdev_get_by_flags_rcu() explicitly use READ_ONCE(dev->flags).
  3. Violation and KCSAN Splat:

    • Because dev->flags is modified by __dev_change_flags() under RTNL while concurrently read without RTNL lock in netif_is_bond_master() (under rcu_read_lock()), and neither side uses atomic access annotations (WRITE_ONCE() / READ_ONCE()), the compiler is theoretically permitted to generate store/load splitting or tearing. KCSAN detects this concurrent unmarked read and write on dev->flags and reports a data race.
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
08ba6f15 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter (5) 2026/11/18 22:50 2026/11/18 22:50 2026/11/18 23:23 2006bdcc
3b044bc5 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter (5) 2026/11/18 22:49 2026/11/18 22:49 2026/11/18 23:02 2006bdcc
▶ ▼ Similar bugs (4)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter net 6 1 1446d 1446d 0/29 auto-obsoleted due to no activity on 2023/01/13 20:31
upstream KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter (3) net 6 1 952d 952d 0/29 auto-obsoleted due to no activity on 2024/05/15 02:59
upstream KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter (4) net 6 2 608d 659d 0/29 auto-obsoleted due to no activity on 2025/05/15 22:26
upstream KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter (2) net 6 1 1220d 1220d 0/29 auto-obsoleted due to no activity on 2023/08/21 12:02

Sample crash report:
==================================================================
BUG: KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter

read-write to 0xffff88811f1610b0 of 4 bytes by task 4617 on cpu 0:
 __dev_change_flags+0x10c/0x490 net/core/dev.c:9996
 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

read to 0xffff88811f1610b0 of 4 bytes by task 4341 on cpu 1:
 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

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 4341 Comm: kworker/u8:14 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
Workqueue: gid-cache-wq netdevice_event_work_handler
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/18 21:47 upstream 4405c18c95d2 2006bdcc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter
2026/11/18 09:17 upstream 20eef29b7c84 eb4895d7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter
2026/11/17 21:53 upstream 63fdb511c27a 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter
2026/11/17 18:02 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter
2026/11/17 10:13 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter
2026/11/17 08:03 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __dev_change_flags / is_ndev_for_default_gid_filter
* Struck through repros no longer work on HEAD.