KCSAN: data-race in capable / posixtimer_send_sigqueue

Status: moderation: reported on 2026/11/18 05:19
Subsystems: kernel
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+ed63626b2df76b1c6ca3@syzkaller.appspotmail.com
First crash: 1d03h, last: 18h25m
✨ AI-generated root cause summary:

A data race was detected by KCSAN between task-context flag modification and an interrupt-context check in POSIX timer signal delivery. In kernel/capability.c:ns_capable_common(), a running task updates its per-task flags via an unmarked read-modify-write (current->flags |= PF_SUPERPRIV). When interrupted on the same CPU by a local APIC timer interrupt, posixtimer_get_target() in kernel/signal.c performs an unmarked plain read of current->flags to verify !(current->flags & PF_EXITING) before redirecting a process-wide timer signal to current. Because current->flags is routinely updated in task context without disabling local interrupts, the unannotated interrupt read races with the interrupted task's update.

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

Technical Mechanism and Root Cause

1. Functions, Structs, and Fields Involved

  • struct task_struct::flags (include/linux/sched.h): An unsigned int field containing per-task process flags (PF_*). By design, only current writes to its own flags, but writes are frequently performed with plain C read-modify-write operations (current->flags |= ...) without disabling local interrupts.
  • ns_capable_common() (kernel/capability.c:343): Updates current->flags |= PF_SUPERPRIV; when a capability check succeeds.
  • posixtimer_get_target() (kernel/signal.c:2022-2030): Selects the target task for delivering a POSIX timer signal. For process-targeted timers (PIDTYPE_TGID), it attempts to target current if current belongs to the same thread group, provided !(current->flags & PF_EXITING).
  • posixtimer_send_sigqueue() (kernel/signal.c:2046): Invoked from POSIX timer expiry callback posix_timer_fn() via posix_timer_queue_signal() in hardirq context (hrtimer_interrupt).

2. Triggering Flow and Data-Race Mechanism

  1. Task-Context Flag Modification: Task 12250 on CPU 0 invokes a system call (__do_sys_acct) that executes capable() -> ns_capable() -> ns_capable_common(). Upon verifying the capability, line 343 executes:

    current->flags |= PF_SUPERPRIV;
    

    This is an unmarked 4-byte read-modify-write on current->flags executed with local IRQs enabled.

  2. Hardirq Interruption on the Same CPU: While task 12250 is running on CPU 0, a local APIC timer interrupt occurs on CPU 0 (sysvec_apic_timer_interrupt). The hardirq handler runs hrtimer_interrupt() -> __hrtimer_run_queues() -> posix_timer_fn() -> posix_timer_queue_signal() -> posixtimer_send_sigqueue().

  3. Interrupt-Context Read: Inside posixtimer_send_sigqueue(), posixtimer_get_target() is called under rcu_read_lock():

    static inline struct task_struct *posixtimer_get_target(struct k_itimer *tmr)
    {
        struct task_struct *t = pid_task(tmr->it_pid, tmr->it_pid_type);
    
        if (t && tmr->it_pid_type != PIDTYPE_PID &&
            same_thread_group(t, current) && !(current->flags & PF_EXITING))
            t = current;
        return t;
    }
    

    In interrupt context, current points to the interrupted task on CPU 0 (task 12250). At line 2027, posixtimer_get_target() performs a plain, unmarked 4-byte read of current->flags to check bit PF_EXITING.

  4. KCSAN Detection: Because current->flags was being modified in task context without IRQs disabled, KCSAN detected a concurrent/reentrant read vs. read-modify-write data race on the same 4-byte memory location (&current->flags).

3. Invariants and Fix

  • Per include/linux/sched.h, task_struct::flags is owned by current. While process context updates various flags without disabling interrupts, hardirq context only reads current->flags and never writes to it.
  • Because PF_EXITING (bit 0x4) is set only once in exit_signals() under &tsk->sighand->siglock with IRQs disabled and is never cleared, reading current->flags in posixtimer_get_target() is functionally safe against word tearing and bit corruption on aligned 32-bit words, but violates the C memory model and KCSAN rules regarding unmarked concurrent accesses.
  • To silence the warning, reading current->flags in posixtimer_get_target() should be annotated with READ_ONCE() or data_race().
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
1bc34e6f assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in capable / posixtimer_send_sigqueue 2026/11/18 05:03 2026/11/18 05:03 2026/11/18 05:34 ca622473
5c138805 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in capable / posixtimer_send_sigqueue 2026/11/18 05:03 2026/11/18 05:03 2026/11/18 05:13 ca622473

Sample crash report:
==================================================================
BUG: KCSAN: data-race in capable / posixtimer_send_sigqueue

read to 0xffff8881049be7ac of 4 bytes by interrupt on cpu 0:
 posixtimer_get_target kernel/signal.c:2027 [inline]
 posixtimer_send_sigqueue+0xd8/0x8d0 kernel/signal.c:2056
 posix_timer_queue_signal kernel/time/posix-timers.c:365 [inline]
 posix_timer_fn+0x93/0xc0 kernel/time/posix-timers.c:380
 __run_hrtimer kernel/time/hrtimer.c:2079 [inline]
 __hrtimer_run_queues+0x1f8/0x540 kernel/time/hrtimer.c:2136
 hrtimer_interrupt+0x27b/0x870 kernel/time/hrtimer.c:2255
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1051 [inline]
 __sysvec_apic_timer_interrupt+0x5f/0x1f0 arch/x86/kernel/apic/apic.c:1068
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
 sysvec_apic_timer_interrupt+0x6f/0x80 arch/x86/kernel/apic/apic.c:1062
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674
 native_pause arch/x86/include/asm/vdso/processor.h:13 [inline]
 delay_tsc+0x43/0xa0 arch/x86/lib/delay.c:76
 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
 ns_capable_common kernel/capability.c:343 [inline]
 ns_capable kernel/capability.c:362 [inline]
 capable+0x81/0xb0 kernel/capability.c:415
 __do_sys_acct kernel/acct.c:297 [inline]
 __se_sys_acct+0x2d/0x550 kernel/acct.c:293
 __x64_sys_acct+0x1f/0x30 kernel/acct.c:293
 x64_sys_call+0x1461/0x2550 arch/x86/include/generated/asm/syscalls_64.h:164
 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-write to 0xffff8881049be7ac of 4 bytes by task 12250 on cpu 0:
 ns_capable_common kernel/capability.c:343 [inline]
 ns_capable kernel/capability.c:362 [inline]
 capable+0x81/0xb0 kernel/capability.c:415
 __do_sys_acct kernel/acct.c:297 [inline]
 __se_sys_acct+0x2d/0x550 kernel/acct.c:293
 __x64_sys_acct+0x1f/0x30 kernel/acct.c:293
 x64_sys_call+0x1461/0x2550 arch/x86/include/generated/asm/syscalls_64.h:164
 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: 12250 Comm: syz.0.1758 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

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