KCSAN: data-race in acct_account_cputime / ns_capable

Status: moderation: reported on 2026/11/20 00:07
Subsystems: kernel
Labels: race:benign prio:low
[Documentation on labels]
Reported-by: syzbot+05f4ee3b6f5e60e8024f@syzkaller.appspotmail.com
First crash: 2d23h, last: 2d08h
✨ AI-generated root cause summary:

A data race occurs on struct task_struct::flags between process context and hardirq context on the same CPU. In ns_capable_common() (kernel/capability.c:343), the task non-atomically updates current->flags with PF_SUPERPRIV while hard interrupts are enabled. When the local timer interrupt fires during this window, the tick accounting path invokes __acct_update_integrals() (kernel/tsacct.c:130 via acct_account_cputime()), which performs an unmarked plain read of tsk->flags to check for PF_KTHREAD, triggering a KCSAN data-race report.

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

Technical Cause of the Bug

The reported KCSAN bug is a data race on struct task_struct::flags (4-byte unsigned int field located at byte offset 0x2c / bit offset 352, matching reported address 0xffff888101d322ac).

1. Conflicting Accesses and Call Chains

  • Writer (Read-Modify-Write in Process Context): When a user process performs a privileged operation such as sys_umount(), capability checking in ns_capable() / ns_capable_common() (kernel/capability.c:343) executes:

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

    This is a plain, unmarked read-modify-write on current->flags executed in task context with local hardware interrupts enabled.

  • Reader (Plain Read in Hardirq Context): On the same CPU, a local APIC timer interrupt fires (sysvec_apic_timer_interrupt $\to$ hrtimer_interrupt $\to$ tick_nohz_handler $\to$ update_process_times $\to$ account_process_tick $\to$ account_system_index_time / account_user_time). This tick accounting path calls acct_account_cputime(p) (kernel/tsacct.c:170), which inlines __acct_update_integrals() (kernel/tsacct.c:130):

    static void __acct_update_integrals(struct task_struct *tsk,
                        u64 utime, u64 stime)
    {
        u64 time, delta;
    
        if (unlikely(!tsk->mm || (tsk->flags & PF_KTHREAD)))
            return;
    ...
    

    Here, tsk is current. __acct_update_integrals() performs a plain, unmarked read of tsk->flags to test PF_KTHREAD.

2. Root Cause Mechanism

  • Commit 5e65b5ca7d4e ("tsacct: skip all kernel threads") introduced the check (tsk->flags & PF_KTHREAD) into __acct_update_integrals() to skip summing RSS for kernel threads temporarily borrowing an mm via use_mm().
  • However, task_struct::flags is modified concurrently by process-context code without disabling local hard interrupts (such as setting PF_SUPERPRIV in ns_capable_common(), or other flags across the kernel).
  • Because neither access is marked using LKMM concurrency primitives (READ_ONCE() or data_race()), when the timer interrupt interrupts the task during the KCSAN watchpoint delay window on current->flags, KCSAN detects concurrent unmarked memory accesses on the same CPU and flags a data race.

3. Invariants and Resolution

  • PF_KTHREAD is established during process creation (copy_process() in kernel/fork.c / init_idle() in kernel/sched/core.c) and remains strictly immutable for the lifetime of the task.
  • Because the hardirq handler only reads tsk->flags and never writes to it, it does not clobber the task's read-modify-write operation, and 32-bit aligned accesses do not tear.
  • In accordance with similar lockless PF_KTHREAD inspections in the kernel (e.g., to_kthread() annotated via commit fd00a46e36a12), the plain read in __acct_update_integrals() should be annotated with READ_ONCE() (i.e. READ_ONCE(tsk->flags) & PF_KTHREAD) or data_race().
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
2d8036ba assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in acct_account_cputime / ns_capable 2026/11/19 13:07 2026/11/19 13:07 2026/11/19 13:24 2006bdcc
0de87ebe assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in acct_account_cputime / ns_capable 2026/11/19 12:52 2026/11/19 12:52 2026/11/19 13:07 2006bdcc

Sample crash report:
==================================================================
BUG: KCSAN: data-race in acct_account_cputime / ns_capable

read to 0xffff888101d322ac of 4 bytes by interrupt on cpu 0:
 __acct_update_integrals kernel/tsacct.c:130 [inline]
 acct_account_cputime+0x61/0x1a0 kernel/tsacct.c:170
 update_process_times+0x21/0x190 kernel/time/timer.c:2474
 tick_sched_handle kernel/time/tick-sched.c:296 [inline]
 tick_nohz_handler+0x241/0x3d0 kernel/time/tick-sched.c:317
 __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
 __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
 ns_capable_common kernel/capability.c:343 [inline]
 ns_capable+0x80/0xb0 kernel/capability.c:362
 may_mount fs/namespace.c:2065 [inline]
 can_umount fs/namespace.c:2082 [inline]
 path_umount+0x95/0x900 fs/namespace.c:2101
 ksys_umount fs/namespace.c:2126 [inline]
 __do_sys_umount fs/namespace.c:2131 [inline]
 __se_sys_umount fs/namespace.c:2129 [inline]
 __x64_sys_umount+0xb6/0xe0 fs/namespace.c:2129
 x64_sys_call+0x225e/0x2550 arch/x86/include/generated/asm/syscalls_64.h:167
 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 0xffff888101d322ac of 4 bytes by task 3298 on cpu 0:
 ns_capable_common kernel/capability.c:343 [inline]
 ns_capable+0x80/0xb0 kernel/capability.c:362
 may_mount fs/namespace.c:2065 [inline]
 can_umount fs/namespace.c:2082 [inline]
 path_umount+0x95/0x900 fs/namespace.c:2101
 ksys_umount fs/namespace.c:2126 [inline]
 __do_sys_umount fs/namespace.c:2131 [inline]
 __se_sys_umount fs/namespace.c:2129 [inline]
 __x64_sys_umount+0xb6/0xe0 fs/namespace.c:2129
 x64_sys_call+0x225e/0x2550 arch/x86/include/generated/asm/syscalls_64.h:167
 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: 3298 Comm: syz-executor 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 17:04 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in acct_account_cputime / ns_capable
2026/11/17 10:07 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in acct_account_cputime / ns_capable
2026/11/17 01:56 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in acct_account_cputime / ns_capable
* Struck through repros no longer work on HEAD.