KCSAN: data-race in __flush_smp_call_function_queue / smp_call_function_single_async

Status: moderation: reported on 2026/11/17 10:58
Subsystems: kernel
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+c6b475cea1b4c8275149@syzkaller.appspotmail.com
First crash: 7h42m, last: 1h09m
✨ AI cause bisection: candidate commits (most relevant first) (AI job):
  5a18ceca6350 smp: Allow smp_call_function_single_async() to insert locked csd
  fd3eafda8f14 sched/core: Remove rq.hrtick_csd_pending
  9213aa4784cf sched: Default enable HRTICK when deferred rearming is enabled
  
✨ AI-generated root cause summary:

In smp_call_function_single_async() (kernel/smp.c), the check for whether the call-single-data object is currently locked (csd->node.u_flags & CSD_FLAG_LOCK) performs an unmarked, plain memory read. While callers serialize submissions of a shared CSD using external locking (such as rq->lock for rq->hrtick_csd), they cannot serialize against the remote target CPU asynchronously completing the IPI in __flush_smp_call_function_queue(), which invokes csd_unlock() using smp_store_release(&csd->node.u_flags, 0). The unmarked read in smp_call_function_single_async() races with the release store in csd_unlock(), lacking acquire semantics to properly synchronize with the remote CPU and triggering a KCSAN data-race report.

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

Technical Root Cause Analysis

1. Involved Functions, Structs, and Files


2. Triggering Mechanism and Race Lifecycle

smp_call_function_single_async() allows callers to queue an asynchronous cross-CPU IPI callback using a caller-managed, preallocated call_single_data_t (csd). As documented in its function header (kernel/smp.c:805-812), the caller is responsible for synchronizing submissions on the given csd object so that calls are serialized among submitters. If a previously submitted call is still in progress on the target CPU, smp_call_function_single_async() returns -EBUSY.

In this report, the shared csd is &rq->hrtick_csd belonging to CPU 0:

  1. Submitter Context (CPU 1):

    • CPU 1 activates or wakes a task belonging to CPU 0 (try_to_wake_up() $\rightarrow$ ttwu_queue() $\rightarrow$ ttwu_do_activate() $\rightarrow$ activate_task() $\rightarrow$ enqueue_task() $\rightarrow$ enqueue_task_fair() $\rightarrow$ hrtick_update() $\rightarrow$ hrtick_start_fair() $\rightarrow$ hrtick_start()).
    • Callers of hrtick_start() hold CPU 0's runqueue lock (rq->__lock), strictly serializing submissions on rq->hrtick_csd.
    • In hrtick_start(), because rq != this_rq(), it calls:
      smp_call_function_single_async(cpu_of(rq), &rq->hrtick_csd);
      
    • In smp_call_function_single_async() (kernel/smp.c:825):
      if (csd->node.u_flags & CSD_FLAG_LOCK) {
          err = -EBUSY;
          goto out;
      }
      
      csd->node.u_flags = CSD_FLAG_LOCK;
      smp_wmb();
      
      err = generic_exec_single(cpu, csd);
      
      Line 825 performs a plain, unmarked memory read of csd->node.u_flags.
  2. IPI Handler Context (CPU 0):

    • CPU 0 is handling a previously queued SMP call function interrupt via generic_smp_call_function_single_interrupt() $\rightarrow$ __flush_smp_call_function_queue().
    • When processing a CSD_TYPE_ASYNC item, CPU 0 unlocks the CSD via csd_unlock(csd) (kernel/smp.c:657):
      static __always_inline void csd_unlock(call_single_data_t *csd)
      {
          WARN_ON(!(csd->node.u_flags & CSD_FLAG_LOCK));
          smp_store_release(&csd->node.u_flags, 0);
      }
      
      This executes a marked release write to csd->node.u_flags (kernel/smp.c:441).

3. Violated Synchronization and Memory Invariant

While submitters serialize with each other using external locks (rq->__lock), they cannot hold locks that serialize against __flush_smp_call_function_queue(), which runs asynchronously in interrupt context on the target CPU. Checking whether the previous async request has finished requires inspecting csd->node.u_flags.

  • csd_unlock() writes 0 using smp_store_release(&csd->node.u_flags, 0) so that prior reads of csd->func, csd->info, and list nodes are ordered before clearing CSD_FLAG_LOCK.
  • Conversely, smp_call_function_single_async() reads csd->node.u_flags with a plain, unmarked load at line 825, followed by a plain store at line 830 (csd->node.u_flags = CSD_FLAG_LOCK).
  • The plain load constitutes an unsynchronized, unmarked read concurrent with a marked write (smp_store_release), directly violating LKMM rules and triggering KCSAN. Furthermore, it lacks acquire semantics (such as smp_load_acquire(&csd->node.u_flags) or try_cmpxchg_acquire()), failing to establish a formal acquire-release pairing with csd_unlock() before reusing the csd node.
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
a5eea656 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in __flush_smp_call_function_queue / smp_call_function_single_async 2026/11/17 10:57 2026/11/17 10:57 2026/11/17 11:31 a3e64cfc
478a6320 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in __flush_smp_call_function_queue / smp_call_function_single_async 2026/11/17 10:50 2026/11/17 10:50 2026/11/17 10:57 a3e64cfc
5e5e426b bisect-cause ❓ KCSAN: data-race in __flush_smp_call_function_queue / smp_call_function_single_async 2026/11/17 10:11 2026/11/17 10:11 2026/11/17 11:16 a3e64cfc

Sample crash report:
==================================================================
BUG: KCSAN: data-race in __flush_smp_call_function_queue / smp_call_function_single_async

write (marked) to 0xffff888237c2cc08 of 4 bytes by interrupt on cpu 0:
 csd_unlock kernel/smp.c:441 [inline]
 __flush_smp_call_function_queue+0x47b/0x900 kernel/smp.c:657
 generic_smp_call_function_single_interrupt+0x13/0x20 kernel/smp.c:544
 __sysvec_call_function_single+0x24/0x120 arch/x86/kernel/smp.c:272
 instr_sysvec_call_function_single arch/x86/kernel/smp.c:267 [inline]
 sysvec_call_function_single+0x66/0x80 arch/x86/kernel/smp.c:267
 asm_sysvec_call_function_single+0x1a/0x20 arch/x86/include/asm/idtentry.h:681
 __preempt_count_dec_and_test arch/x86/include/asm/preempt.h:123 [inline]
 __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:211 [inline]
 _raw_spin_unlock_irqrestore+0x1a/0x30 kernel/locking/spinlock.c:221
 spin_unlock_irqrestore include/linux/spinlock.h:425 [inline]
 lruvec_unlock_irqrestore include/linux/memcontrol.h:1577 [inline]
 folio_batch_move_lru+0x384/0x420 mm/folio.c:200
 __folio_batch_add_and_move+0x163/0x1e0 mm/folio.c:225
 folio_add_lru+0x9f/0x190 mm/folio.c:492
 shmem_alloc_and_add_folio mm/shmem.c:2285 [inline]
 shmem_get_folio_gfp+0x7c1/0xcb0 mm/shmem.c:2780
 shmem_fault+0xf4/0x260 mm/shmem.c:2974
 __do_fault mm/memory.c:5677 [inline]
 do_read_fault mm/memory.c:6112 [inline]
 do_fault mm/memory.c:6246 [inline]
 do_pte_missing mm/memory.c:4778 [inline]
 handle_pte_fault mm/memory.c:6665 [inline]
 __handle_mm_fault mm/memory.c:6817 [inline]
 handle_mm_fault+0x2183/0x3880 mm/memory.c:6984
 faultin_page mm/gup.c:1130 [inline]
 __get_user_pages+0xf69/0x19e0 mm/gup.c:1432
 populate_vma_page_range+0x16b/0x1b0 mm/gup.c:1868
 __mm_populate+0x1b0/0x2c0 mm/gup.c:1971
 mm_populate include/linux/mm.h:4451 [inline]
 vm_mmap_pgoff+0x272/0x320 mm/util.c:586
 ksys_mmap_pgoff+0xc1/0x310 mm/mmap.c:619
 x64_sys_call+0x23b3/0x2550 arch/x86/include/generated/asm/syscalls_64.h:10
 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 0xffff888237c2cc08 of 4 bytes by interrupt on cpu 1:
 smp_call_function_single_async+0x28/0xb0 kernel/smp.c:825
 enqueue_task kernel/sched/core.c:2197 [inline]
 activate_task kernel/sched/core.c:2237 [inline]
 ttwu_do_activate+0x65/0x210 kernel/sched/core.c:3903
 ttwu_queue kernel/sched/core.c:4156 [inline]
 try_to_wake_up+0x3f8/0x6b0 kernel/sched/core.c:4489
 rcuwait_wake_up+0x35/0x50 kernel/exit.c:339
 nbcon_kthread_wake kernel/printk/internal.h:131 [inline]
 nbcon_irq_work+0x19/0x20 kernel/printk/nbcon.c:1290
 irq_work_single kernel/irq_work.c:221 [inline]
 irq_work_run_list kernel/irq_work.c:252 [inline]
 irq_work_run+0x242/0x2f0 kernel/irq_work.c:260
 __sysvec_irq_work+0x24/0x120 arch/x86/kernel/irq_work.c:22
 instr_sysvec_irq_work arch/x86/kernel/irq_work.c:17 [inline]
 sysvec_irq_work+0x66/0x80 arch/x86/kernel/irq_work.c:17
 asm_sysvec_irq_work+0x1a/0x20 arch/x86/include/asm/idtentry.h:710
 __preempt_count_dec_and_test arch/x86/include/asm/preempt.h:123 [inline]
 __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:211 [inline]
 _raw_spin_unlock_irqrestore+0x1a/0x30 kernel/locking/spinlock.c:221
 srcu_funnel_gp_start kernel/rcu/srcutree.c:1213 [inline]
 srcu_gp_start_if_needed+0x84d/0xa70 kernel/rcu/srcutree.c:1475
 srcu_do_enqueue kernel/rcu/srcutree.c:1520 [inline]
 __call_srcu+0x15c/0x260 kernel/rcu/srcutree.c:1570
 __synchronize_srcu+0x123/0x170 kernel/rcu/srcutree.c:1681
 synchronize_srcu+0x1c5/0x1e0 kernel/rcu/srcutree.c:-1
 fsnotify_connector_destroy_workfn+0x4e/0x90 fs/notify/mark.c:385
 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: 13 Comm: kworker/u8:0 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
Workqueue: events_unbound fsnotify_connector_destroy_workfn
==================================================================

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