KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault

Status: moderation: reported on 2026/11/20 00:04
Subsystems: perf
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+4f86b1de059732e15a1c@syzkaller.appspotmail.com
First crash: 2d21h, last: 2d06h
✨ AI-generated root cause summary:

KCSAN reported a data race on current->pagefault_disabled between task context and an interrupt handler executing on the same CPU. In task context, strncpy_from_kernel_nofault() (mm/maccess.c) invoked pagefault_disable() and pagefault_enable(), which perform plain, unmarked read-modify-write operations (current->pagefault_disabled++ and current->pagefault_disabled-- in include/linux/uaccess.h) with interrupts enabled. An APIC timer interrupt occurred during task execution and triggered a perf sample callchain walk (perf_callchain_user() in arch/x86/events/core.c), which also invoked pagefault_disable() / pagefault_enable() to read user stack frames, accessing the interrupted task's pagefault_disabled counter without synchronization. Under the Linux Kernel Memory Model, concurrent unmarked accesses between task and interrupt contexts constitute a data race.

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

Root Cause Analysis

1. Functions, Structs, and Variables Involved

  • Variable / Field: current->pagefault_disabled (struct task_struct::pagefault_disabled, declared in include/linux/sched.h).
  • Accessors:
  • Task Context Callers:
    • strncpy_from_kernel_nofault() in mm/maccess.c:95, 101 (invoked via bpf_probe_read_kernel_str()).
  • Interrupt / NMI Context Callers:
    • perf_callchain_user() in arch/x86/events/core.c:3468, 3492 (and perf_callchain_user32() in lines 3412, 3429), invoked via get_perf_callchain() during an APIC timer interrupt (hrtimer_interrupt -> perf_swevent_hrtimer).

2. Technical Mechanism and Trigger Condition

In Linux, task_struct::pagefault_disabled is an integer counter tracking nesting depth to indicate whether page faults may sleep or must immediately divert to the exception fixup table.

  1. Unmarked Read-Modify-Write in include/linux/uaccess.h:

    static __always_inline void pagefault_disabled_inc(void)
    {
        current->pagefault_disabled++;
    }
    
    static __always_inline void pagefault_disabled_dec(void)
    {
        current->pagefault_disabled--;
    }
    

    These modifications are plain, unmarked operations on current->pagefault_disabled without atomic primitives, READ_ONCE()/WRITE_ONCE(), or local atomic types (local_t).

  2. Absence of IRQ Disabling in Task Context: Functions such as strncpy_from_kernel_nofault() (and various usercopy/atomic routines) call pagefault_disable() with local interrupts enabled.

  3. Re-entrant Modification by Interrupt Handlers: While task context on CPU 1 is executing pagefault_disable() or pagefault_enable(), a hardware or timer interrupt (such as an APIC timer interrupt triggering perf_swevent_hrtimer) can fire on the same CPU. When the event overflows and samples user callchains, get_perf_callchain() calls architecture-specific perf_callchain_user() (arch/x86/events/core.c). To safely traverse user frame pointers without faulting, perf_callchain_user() also calls pagefault_disable() and pagefault_enable(), modifying current->pagefault_disabled of the interrupted task.

  4. KCSAN Data-Race Detection: With CONFIG_KCSAN_INTERRUPT_WATCHER=y, KCSAN monitors accesses between interrupt handlers and interrupted task code on the same CPU. When kcsan_setup_watchpoint() stalls during the task context's access to current->pagefault_disabled, the timer interrupt executes concurrently on that same CPU and performs another unmarked read-write on the same memory address (0xffff88810283bfd4), triggering the KCSAN data-race report.


3. Invariants and Resolution

Under the Linux Kernel Memory Model (LKMM), shared variables accessed concurrently across execution contexts (including task vs. interrupt contexts) must use marked accesses or synchronization. Although the interrupt handler executes in strict LIFO order and balances increments and decrements, plain C ++/-- accesses violate LKMM assumptions regarding asynchronous re-entrancy. Fixing the warning typically involves using READ_ONCE()/WRITE_ONCE() pairs or transitioning task_struct::pagefault_disabled to an interrupt-safe type such as local_t.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
56266912 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault 2026/11/19 12:25 2026/11/19 12:25 2026/11/19 12:45 2006bdcc
e41369d1 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault 2026/11/19 12:22 2026/11/19 12:22 2026/11/19 13:15 2006bdcc

Sample crash report:
==================================================================
BUG: KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault

read-write to 0xffff88810283bfd4 of 4 bytes by interrupt on cpu 1:
 pagefault_disabled_inc include/linux/uaccess.h:248 [inline]
 pagefault_disable include/linux/uaccess.h:265 [inline]
 perf_callchain_user+0x171/0x910 arch/x86/events/core.c:3468
 get_perf_callchain+0x5c4/0x700 kernel/events/callchain.c:270
 perf_callchain+0x224/0x270 kernel/events/core.c:8761
 perf_sample_save_callchain include/linux/perf_event.h:1385 [inline]
 perf_prepare_sample+0x1f5/0x1550 kernel/events/core.c:8829
 bpf_overflow_handler kernel/events/core.c:10821 [inline]
 __perf_event_overflow+0x308/0x950 kernel/events/core.c:10921
 perf_event_overflow kernel/events/core.c:11004 [inline]
 perf_swevent_hrtimer+0x293/0x320 kernel/events/core.c:12424
 __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
 pagefault_disabled_inc include/linux/uaccess.h:248 [inline]
 pagefault_disable include/linux/uaccess.h:265 [inline]
 strncpy_from_kernel_nofault+0x67/0x120 mm/maccess.c:95
 bpf_probe_read_kernel_str_common kernel/trace/bpf_trace.c:294 [inline]
 ____bpf_probe_read_kernel_str kernel/trace/bpf_trace.c:303 [inline]
 bpf_probe_read_kernel_str+0x2a/0x70 kernel/trace/bpf_trace.c:300
 bpf_prog_a75bc605385d949b+0x43/0x49
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_prog_run_pin_on_cpu include/linux/filter.h:837 [inline]
 bpf_flow_dissect+0x157/0x360 net/core/flow_dissector.c:1024
 bpf_prog_test_run_flow_dissector+0x25d/0x360 net/bpf/test_run.c:1565
 bpf_prog_test_run+0x21b/0x360 kernel/bpf/syscall.c:4860
 __sys_bpf+0x914/0xc50 kernel/bpf/syscall.c:6478
 __do_sys_bpf kernel/bpf/syscall.c:6582 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:6579 [inline]
 __x64_sys_bpf+0x69/0x80 kernel/bpf/syscall.c:6579
 x64_sys_call+0xf26/0x2550 arch/x86/include/generated/asm/syscalls_64.h:322
 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 0xffff88810283bfd4 of 4 bytes by task 9219 on cpu 1:
 pagefault_disabled_inc include/linux/uaccess.h:248 [inline]
 pagefault_disable include/linux/uaccess.h:265 [inline]
 strncpy_from_kernel_nofault+0x67/0x120 mm/maccess.c:95
 bpf_probe_read_kernel_str_common kernel/trace/bpf_trace.c:294 [inline]
 ____bpf_probe_read_kernel_str kernel/trace/bpf_trace.c:303 [inline]
 bpf_probe_read_kernel_str+0x2a/0x70 kernel/trace/bpf_trace.c:300
 bpf_prog_a75bc605385d949b+0x43/0x49
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_prog_run_pin_on_cpu include/linux/filter.h:837 [inline]
 bpf_flow_dissect+0x157/0x360 net/core/flow_dissector.c:1024
 bpf_prog_test_run_flow_dissector+0x25d/0x360 net/bpf/test_run.c:1565
 bpf_prog_test_run+0x21b/0x360 kernel/bpf/syscall.c:4860
 __sys_bpf+0x914/0xc50 kernel/bpf/syscall.c:6478
 __do_sys_bpf kernel/bpf/syscall.c:6582 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:6579 [inline]
 __x64_sys_bpf+0x69/0x80 kernel/bpf/syscall.c:6579
 x64_sys_call+0xf26/0x2550 arch/x86/include/generated/asm/syscalls_64.h:322
 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: 1 UID: 0 PID: 9219 Comm: syz.8.1958 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================
==================================================================
BUG: KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault

read-write to 0xffff88810283bfd4 of 4 bytes by interrupt on cpu 1:
 pagefault_disabled_inc include/linux/uaccess.h:248 [inline]
 pagefault_disable include/linux/uaccess.h:265 [inline]
 perf_callchain_user+0x171/0x910 arch/x86/events/core.c:3468
 get_perf_callchain+0x5c4/0x700 kernel/events/callchain.c:270
 perf_callchain+0x224/0x270 kernel/events/core.c:8761
 perf_sample_save_callchain include/linux/perf_event.h:1385 [inline]
 perf_prepare_sample+0x1f5/0x1550 kernel/events/core.c:8829
 bpf_overflow_handler kernel/events/core.c:10821 [inline]
 __perf_event_overflow+0x308/0x950 kernel/events/core.c:10921
 perf_event_overflow kernel/events/core.c:11004 [inline]
 perf_swevent_hrtimer+0x293/0x320 kernel/events/core.c:12424
 __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
 rdtsc_ordered arch/x86/include/asm/tsc.h:57 [inline]
 delay_tsc+0x5b/0xa0 arch/x86/lib/delay.c:70
 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
 pagefault_disabled_dec include/linux/uaccess.h:253 [inline]
 pagefault_enable include/linux/uaccess.h:280 [inline]
 strncpy_from_kernel_nofault+0xde/0x120 mm/maccess.c:-1
 bpf_probe_read_kernel_str_common kernel/trace/bpf_trace.c:294 [inline]
 ____bpf_probe_read_kernel_str kernel/trace/bpf_trace.c:303 [inline]
 bpf_probe_read_kernel_str+0x2a/0x70 kernel/trace/bpf_trace.c:300
 bpf_prog_a75bc605385d949b+0x43/0x49
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_prog_run_pin_on_cpu include/linux/filter.h:837 [inline]
 bpf_flow_dissect+0x157/0x360 net/core/flow_dissector.c:1024
 bpf_prog_test_run_flow_dissector+0x25d/0x360 net/bpf/test_run.c:1565
 bpf_prog_test_run+0x21b/0x360 kernel/bpf/syscall.c:4860
 __sys_bpf+0x914/0xc50 kernel/bpf/syscall.c:6478
 __do_sys_bpf kernel/bpf/syscall.c:6582 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:6579 [inline]
 __x64_sys_bpf+0x69/0x80 kernel/bpf/syscall.c:6579
 x64_sys_call+0xf26/0x2550 arch/x86/include/generated/asm/syscalls_64.h:322
 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 0xffff88810283bfd4 of 4 bytes by task 9219 on cpu 1:
 pagefault_disabled_dec include/linux/uaccess.h:253 [inline]
 pagefault_enable include/linux/uaccess.h:280 [inline]
 strncpy_from_kernel_nofault+0xde/0x120 mm/maccess.c:-1
 bpf_probe_read_kernel_str_common kernel/trace/bpf_trace.c:294 [inline]
 ____bpf_probe_read_kernel_str kernel/trace/bpf_trace.c:303 [inline]
 bpf_probe_read_kernel_str+0x2a/0x70 kernel/trace/bpf_trace.c:300
 bpf_prog_a75bc605385d949b+0x43/0x49
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_prog_run_pin_on_cpu include/linux/filter.h:837 [inline]
 bpf_flow_dissect+0x157/0x360 net/core/flow_dissector.c:1024
 bpf_prog_test_run_flow_dissector+0x25d/0x360 net/bpf/test_run.c:1565
 bpf_prog_test_run+0x21b/0x360 kernel/bpf/syscall.c:4860
 __sys_bpf+0x914/0xc50 kernel/bpf/syscall.c:6478
 __do_sys_bpf kernel/bpf/syscall.c:6582 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:6579 [inline]
 __x64_sys_bpf+0x69/0x80 kernel/bpf/syscall.c:6579
 x64_sys_call+0xf26/0x2550 arch/x86/include/generated/asm/syscalls_64.h:322
 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: 1 UID: 0 PID: 9219 Comm: syz.8.1958 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 18:32 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault
2026/11/17 18:32 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault
2026/11/17 11:28 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault
2026/11/17 11:28 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in perf_callchain_user / strncpy_from_kernel_nofault
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 perf_callchain_user / strncpy_from_kernel_nofault
* Struck through repros no longer work on HEAD.