KCSAN: data-race in capable_wrt_inode_uidgid / posixtimer_send_sigqueue

Status: moderation: reported on 2026/11/17 15:54
Subsystems: kernel
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+642b44a2c031c8743f73@syzkaller.appspotmail.com
First crash: 13h51m, last: 5h04m
✨ 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 data race is flagged by KCSAN on current->flags (an unsigned int at offset 0x2c of struct task_struct) between task context and hardirq context on the same CPU. In task context during a setxattr syscall, ns_capable_common() (kernel/capability.c:343) executes an unmarked read-modify-write (current->flags |= PF_SUPERPRIV) with interrupts enabled, which is standard practice for task-private flags. Concurrently, a POSIX interval timer expiry interrupts the CPU in posix_timer_fn(), calling posixtimer_send_sigqueue() -> posixtimer_get_target() (kernel/signal.c:2027), which performs an unmarked, lockless read !(current->flags & PF_EXITING) prior to acquiring sighand->siglock. Because the hardirq read lacks READ_ONCE() or data_race() annotation to pair with the plain compound assignment in task context, KCSAN detects a data race under the Linux Kernel Memory Model.

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

Technical Explanation and Root Cause Analysis

1. Functions, Structs, Fields, and Files Involved


2. Triggering Mechanism and Race Condition

  1. Task Context Read-Modify-Write: In kernel/capability.c:343, when a capability check succeeds, ns_capable_common() performs a plain compound assignment:

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

    Per Linux task lifecycle rules documented in include/linux/sched.h:1839-1848, current->flags is task-private memory written only by the task itself. These updates use standard plain C bitwise operations (|=, &=) without disabling local interrupts.

  2. Hardirq Context Interruption and Plain Read: While task 4219 is executing ns_capable_common() on CPU 0, a local APIC timer interrupt occurs on CPU 0. In hardirq context, hrtimer_interrupt() processes an expiring POSIX interval timer belonging to the process running on CPU 0. posix_timer_fn() invokes posixtimer_send_sigqueue(), which 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;
    }
    

    When tmr->it_pid_type != PIDTYPE_PID (process-wide timer) and same_thread_group(t, current) holds, posixtimer_get_target() performs a lockless read of current->flags & PF_EXITING to determine whether current can be chosen as the target thread to deliver the timer signal (avoiding waking up an idle thread).

  3. Violation and Sanitizer Detection: Because posixtimer_get_target() executes an unmarked load (current->flags) in interrupt context concurrently with an unmarked store (current->flags |= PF_SUPERPRIV) in interrupted thread context on the same CPU, KCSAN detects an unsynchronized read-write concurrency under the Linux Kernel Memory Model (LKMM) and emits the data-race report.


3. Invariant Assessment

  • posixtimer_get_target() is merely a lockless target selection heuristic. After calling posixtimer_get_target(tmr), posixtimer_send_sigqueue() proceeds to acquire lock_task_sighand(t, &flags) (holding t->sighand->siglock) and calls task_can_queue_signal(t, tmr->it_pid_type) under lock.
  • PF_EXITING is written only once during task termination in exit_signals() (kernel/signal.c:3211) under tsk->sighand->siglock with interrupts disabled.
  • Because posixtimer_get_target() reads current->flags without writing to it, no task-context update to current->flags can be lost, making the race benign in production kernels. Annotating the read with READ_ONCE() or data_race() resolves the KCSAN warning.
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
786dfc6d assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in capable_wrt_inode_uidgid / posixtimer_send_sigqueue 2026/11/17 15:47 2026/11/17 15:47 2026/11/17 16:45 ca622473
30c0309f assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in capable_wrt_inode_uidgid / posixtimer_send_sigqueue 2026/11/17 15:44 2026/11/17 15:44 2026/11/17 15:54 ca622473
eab7f01f bisect-cause ❓ KCSAN: data-race in capable_wrt_inode_uidgid / posixtimer_send_sigqueue 2026/11/17 15:27 2026/11/17 15:27 2026/11/17 15:58 ca622473

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

read to 0xffff88810499c52c 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_wrt_inode_uidgid+0xa2/0x190 kernel/capability.c:495
 cap_convert_nscap+0x121/0x340 security/commoncap.c:587
 vfs_setxattr+0xb0/0x2b0 fs/xattr.c:336
 do_setxattr fs/xattr.c:662 [inline]
 filename_setxattr+0x1c4/0x410 fs/xattr.c:690
 path_setxattrat+0x2c1/0x320 fs/xattr.c:734
 __do_sys_setxattr fs/xattr.c:768 [inline]
 __se_sys_setxattr fs/xattr.c:764 [inline]
 __x64_sys_setxattr+0x6e/0x90 fs/xattr.c:764
 x64_sys_call+0xf6c/0x2550 arch/x86/include/generated/asm/syscalls_64.h:189
 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 0xffff88810499c52c of 4 bytes by task 4219 on cpu 0:
 ns_capable_common kernel/capability.c:343 [inline]
 ns_capable kernel/capability.c:362 [inline]
 capable_wrt_inode_uidgid+0xa2/0x190 kernel/capability.c:495
 cap_convert_nscap+0x121/0x340 security/commoncap.c:587
 vfs_setxattr+0xb0/0x2b0 fs/xattr.c:336
 do_setxattr fs/xattr.c:662 [inline]
 filename_setxattr+0x1c4/0x410 fs/xattr.c:690
 path_setxattrat+0x2c1/0x320 fs/xattr.c:734
 __do_sys_setxattr fs/xattr.c:768 [inline]
 __se_sys_setxattr fs/xattr.c:764 [inline]
 __x64_sys_setxattr+0x6e/0x90 fs/xattr.c:764
 x64_sys_call+0xf6c/0x2550 arch/x86/include/generated/asm/syscalls_64.h:189
 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: 4219 Comm: syz.0.182 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

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