KCSAN: data-race in ns_capable_noaudit / posixtimer_send_sigqueue

Status: moderation: reported on 2026/11/18 00:03
Subsystems: kernel
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+82f093f6fc44ab5baeac@syzkaller.appspotmail.com
First crash: 5h12m, last: 5h12m
✨ AI cause bisection: introduced by (AI job) :
commit d2710c8d938ae6a825a6463158e6e6f31eac792a
Author: Thomas Gleixner <tglx@kernel.org>
Date: Fri Sep 11 09:09:12 2026 +0000

  signal: Prevent exec() race

  
✨ AI-generated root cause summary:

A KCSAN data race occurs between task-context capability checking in ns_capable_common() and hardirq-context POSIX timer signal delivery in posixtimer_get_target(). In task context, ns_capable_common() performs an unmarked non-atomic read-modify-write to update current->flags (current->flags |= PF_SUPERPRIV). When a local timer interrupt fires on the same CPU while the task is in ns_capable_common(), the hardirq handler runs posixtimer_send_sigqueue() -> posixtimer_get_target(), which performs an unsynchronized read of current->flags to check !(current->flags & PF_EXITING). Because neither access uses atomic primitives or annotations (such as READ_ONCE or data_race()), KCSAN flags the concurrent 4-byte read and read-write accesses on task_struct::flags.

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

Technical Explanation of Root Cause

1. Involved Structs, Fields, and Functions


2. Triggering Mechanism and Detailed Breakdown

  1. Task-Context Execution (kernel/capability.c:343): During syscall execution (such as io_uring_setup), a thread on CPU 0 checks whether it has a specific capability using ns_capable_noaudit(). When the check succeeds, ns_capable_common() records capability usage by modifying current->flags:

    capable = security_capable(current_cred(), ns, cap, opts);
    if (capable == 0) {
        current->flags |= PF_SUPERPRIV;
        return true;
    }
    

    This operation executes in task context without acquiring locks (which is standard kernel practice because task_struct::flags contains task-local PF_* flags typically modified only by the task itself).

  2. Hardirq-Context Interruption (kernel/signal.c:2027): While CPU 0 is in the middle of executing ns_capable_common() (where KCSAN placed a memory watchpoint on current->flags), a local APIC timer interrupt occurs on CPU 0 with local IRQs enabled. The timer interrupt runs hrtimer_interrupt, which fires an expired POSIX interval timer (posix_timer_fn()).

    To queue the timer signal, posixtimer_send_sigqueue() calls posixtimer_get_target(tmr):

    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;
    }
    

    For process-wide timers (tmr->it_pid_type != PIDTYPE_PID), this optimization prefers delivering the signal to current if current belongs to the same thread group and is not exiting (!(current->flags & PF_EXITING)), avoiding waking up an idle thread. On CPU 0, current is the interrupted task.

  3. Data Race Detected by KCSAN: posixtimer_get_target() reads current->flags without synchronization (such as READ_ONCE() or data_race()), while ns_capable_common() performs an unsynchronized read-modify-write on current->flags. KCSAN flags this access as an unsynchronized data race on the 4-byte address of current->flags.


3. Invariants and Correctness Evaluation

  • Benign in Real-World Setups:
    • Interrupt handlers execute strictly between discrete machine instructions.
    • The interrupt handler only reads current->flags to check bit PF_EXITING (0x00000004); it does not write to current->flags.
    • The interrupted task context updates bit PF_SUPERPRIV (0x00000100). On naturally aligned 32-bit accesses, reading current->flags from the hardirq cannot tear or corrupt the field, nor can the read clobber or alter the value written by current->flags |= PF_SUPERPRIV.
    • The PF_EXITING flag is set exclusively by current itself within exit_signals() (kernel/signal.c:3211) while holding spin_lock_irq(&tsk->sighand->siglock) with interrupts disabled. Thus, PF_EXITING cannot change asynchronously while in ns_capable_common() or during interrupt handling on the local CPU.
    • Immediately following target selection, posixtimer_send_sigqueue() acquires lock_task_sighand(t, &flags) and explicitly calls task_can_queue_signal(t, tmr->it_pid_type) with sighand->siglock held before queueing the signal.
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
79c4cbd7 bisect-cause ❓ KCSAN: data-race in ns_capable_noaudit / posixtimer_send_sigqueue 2026/11/17 22:26 2026/11/17 22:26 2026/11/17 22:50 ca622473
68ede53d assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in ns_capable_noaudit / posixtimer_send_sigqueue 2026/11/17 22:21 2026/11/17 22:21 2026/11/17 22:35 ca622473
4f7eb68c assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in ns_capable_noaudit / posixtimer_send_sigqueue 2026/11/17 22:14 2026/11/17 22:14 2026/11/17 22:33 ca622473

Sample crash report:
netlink: 60 bytes leftover after parsing attributes in process `syz.1.31'.
netlink: 60 bytes leftover after parsing attributes in process `syz.1.31'.
==================================================================
BUG: KCSAN: data-race in ns_capable_noaudit / posixtimer_send_sigqueue

read to 0xffff888103a2c52c 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_noaudit+0x83/0xb0 kernel/capability.c:380
 io_uring_create+0x1fb/0x500 io_uring/io_uring.c:3281
 io_uring_setup io_uring/io_uring.c:3379 [inline]
 __do_sys_io_uring_setup io_uring/io_uring.c:3413 [inline]
 __se_sys_io_uring_setup+0x1cb/0x1e0 io_uring/io_uring.c:3404
 __x64_sys_io_uring_setup+0x31/0x40 io_uring/io_uring.c:3404
 x64_sys_call+0x1fbf/0x2550 arch/x86/include/generated/asm/syscalls_64.h:426
 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 0xffff888103a2c52c of 4 bytes by task 3749 on cpu 0:
 ns_capable_common kernel/capability.c:343 [inline]
 ns_capable_noaudit+0x83/0xb0 kernel/capability.c:380
 io_uring_create+0x1fb/0x500 io_uring/io_uring.c:3281
 io_uring_setup io_uring/io_uring.c:3379 [inline]
 __do_sys_io_uring_setup io_uring/io_uring.c:3413 [inline]
 __se_sys_io_uring_setup+0x1cb/0x1e0 io_uring/io_uring.c:3404
 __x64_sys_io_uring_setup+0x31/0x40 io_uring/io_uring.c:3404
 x64_sys_call+0x1fbf/0x2550 arch/x86/include/generated/asm/syscalls_64.h:426
 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: 3749 Comm: syz.1.31 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================
EXT4-fs (loop1): unmounting filesystem 00000000-0000-0000-0000-000000000000.

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