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)
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()
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.