KCSAN: data-race in device_del / rcu_core

Status: moderation: reported on 2026/11/17 15:48
Subsystems: kernel
Labels: race:benign prio:high
[Documentation on labels]
Reported-by: syzbot+84dcd5d1da09793f0c05@syzkaller.appspotmail.com
First crash: 11h45m, last: 11h45m
✨ AI cause bisection: candidate commits (most relevant first) (AI job):
  c1de45ca831a sched/idle: Add support for tasks that inject idle
  3f6d5e6a468d mm: introduce memalloc_flags_{save,restore}
  
✨ AI-generated root cause summary:

A data race occurs on task_struct::flags between process context and interrupt/softirq context. During device unregistration in device_del(), memalloc_noio_restore() calls memalloc_flags_restore(), performing an unmarked plain read-modify-write (current->flags &= ~flags;) to clear PF_MEMALLOC_NOIO with interrupts enabled. An APIC timer interrupt interrupting this task triggers RCU_SOFTIRQ, where rcu_do_batch() calls is_idle_task(current) to check whether callback processing should yield, performing an unmarked plain read (p->flags & PF_IDLE) on the same flags word of the interrupted task. Because neither access uses READ_ONCE()/WRITE_ONCE() or synchronization, KCSAN detects a concurrent read and write to task_struct::flags.

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

Root Cause Analysis

1. Functions, Structs, and Fields Involved


2. Technical Mechanism and Trigger Sequence

  1. Task Context Modification of task_struct::flags: During network namespace cleanup (cleanup_net() -> default_device_exit_batch() -> unregister_netdevice_many_notify() -> netdev_unregister_kobject()), device_del() executes under process context with interrupts enabled. At line 3989 of drivers/base/core.c, device_del() restores allocation flags using:

    memalloc_noio_restore(noio_flag);
    

    This invokes memalloc_flags_restore() in include/linux/sched/mm.h:

    static inline void memalloc_flags_restore(unsigned flags)
    {
        current->flags &= ~flags;
    }
    

    This operation executes an unmarked, non-atomic plain C read-modify-write on current->flags to clear the PF_MEMALLOC_NOIO bit.

  2. Interruption by Timer Softirq: While KCSAN delays the access to instrument concurrent memory accesses (or during this write window on CPU 0), an APIC timer interrupt fires on CPU 0, interrupting the task (PID 1788, kworker). On interrupt exit (__irq_exit_rcu()), pending softirqs are served via handle_softirqs(), which processes RCU_SOFTIRQ via rcu_core() and rcu_do_batch().

  3. Softirq Context Inspection of task_struct::flags: Because softirqs execute on the same CPU in the context of the interrupted task, current remains set to task 1788. In kernel/rcu/tree.c:

    if (in_serving_softirq()) {
        if (count >= bl && (need_resched() || !is_idle_task(current)))
            break;
    

    rcu_do_batch() evaluates is_idle_task(current) to determine whether the RCU callback batch should be broken to prevent starving other tasks or softirqs. is_idle_task() (include/linux/sched.h) executes:

    static __always_inline bool is_idle_task(const struct task_struct *p)
    {
        return !!(p->flags & PF_IDLE);
    }
    

    This is an unmarked plain C read on p->flags (current->flags).

  4. KCSAN Data-Race Detection: Neither the read in is_idle_task() nor the read-modify-write in memalloc_flags_restore() is marked with atomic accessors or READ_ONCE() / WRITE_ONCE(), nor are interrupts disabled during memalloc_flags_restore(). As a result, KCSAN flags the concurrent read and write to current->flags (0xffff8881046722ac) as a data race between task context and softirq context.

▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
d845f7e5 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ✅ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in device_del / rcu_core 2026/11/17 15:10 2026/11/17 15:10 2026/11/17 15:47 ca622473
32801c80 bisect-cause ❓ KCSAN: data-race in device_del / rcu_core 2026/11/17 15:08 2026/11/17 15:08 2026/11/17 16:01 ca622473
1ca73d76 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in device_del / rcu_core 2026/11/17 14:26 2026/11/17 14:26 2026/11/17 15:07 a3e64cfc

Sample crash report:
team_slave_1 (unregistering): left promiscuous mode
team0 (unregistering): Port device team_slave_1 removed
team_slave_0 (unregistering): left promiscuous mode
team0 (unregistering): Port device team_slave_0 removed
==================================================================
BUG: KCSAN: data-race in device_del / rcu_core

read to 0xffff8881046722ac of 4 bytes by interrupt on cpu 0:
 is_idle_task include/linux/sched.h:1988 [inline]
 rcu_do_batch kernel/rcu/tree.c:2658 [inline]
 rcu_core+0x837/0xcb0 kernel/rcu/tree.c:2919
 rcu_core_si+0xd/0x20 kernel/rcu/tree.c:2936
 handle_softirqs+0x109/0x310 kernel/softirq.c:669
 __do_softirq kernel/softirq.c:703 [inline]
 invoke_softirq kernel/softirq.c:542 [inline]
 __irq_exit_rcu+0x40/0xf0 kernel/softirq.c:786
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
 sysvec_apic_timer_interrupt+0x74/0x80 arch/x86/kernel/apic/apic.c:1062
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674
 __preempt_count_add arch/x86/include/asm/preempt.h:98 [inline]
 delay_tsc+0x4b/0xa0 arch/x86/lib/delay.c:77
 udelay include/asm-generic/delay.h:64 [inline]
 delay_access kernel/kcsan/core.c:332 [inline]
 kcsan_setup_watchpoint+0x255/0x3f0 kernel/kcsan/core.c:622
 memalloc_flags_restore include/linux/sched/mm.h:341 [inline]
 memalloc_noio_restore include/linux/sched/mm.h:371 [inline]
 device_del+0x741/0x790 drivers/base/core.c:3989
 netdev_unregister_kobject+0x24e/0x260 net/core/net-sysfs.c:2349
 unregister_netdevice_many_notify+0x11cb/0x15e0 net/core/dev.c:12803
 unregister_netdevice_many net/core/dev.c:12841 [inline]
 default_device_exit_batch+0x411/0x590 net/core/dev.c:13564
 ops_exit_list net/core/net_namespace.c:206 [inline]
 ops_undo_list+0x2c5/0x410 net/core/net_namespace.c:253
 cleanup_net+0x38d/0x5e0 net/core/net_namespace.c:713
 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 0xffff8881046722ac of 4 bytes by task 1788 on cpu 0:
 memalloc_flags_restore include/linux/sched/mm.h:341 [inline]
 memalloc_noio_restore include/linux/sched/mm.h:371 [inline]
 device_del+0x741/0x790 drivers/base/core.c:3989
 netdev_unregister_kobject+0x24e/0x260 net/core/net-sysfs.c:2349
 unregister_netdevice_many_notify+0x11cb/0x15e0 net/core/dev.c:12803
 unregister_netdevice_many net/core/dev.c:12841 [inline]
 default_device_exit_batch+0x411/0x590 net/core/dev.c:13564
 ops_exit_list net/core/net_namespace.c:206 [inline]
 ops_undo_list+0x2c5/0x410 net/core/net_namespace.c:253
 cleanup_net+0x38d/0x5e0 net/core/net_namespace.c:713
 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: 0 UID: 0 PID: 1788 Comm: kworker/u8:9 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
Workqueue: netns cleanup_net
==================================================================
bridge0: port 1(bridge_slave_0) entered disabled state
bridge0: port 2(bridge_slave_1) entered disabled state

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