KCSAN: data-race in hrtimer_interrupt / memcpy_and_pad

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

During clone3()/copy_process(), dup_task_struct() invokes arch_dup_task_struct() to duplicate the parent task_struct (current) via an unmarked bulk memcpy_and_pad() with interrupts enabled. On x86_64 with CONFIG_THREAD_INFO_IN_TASK=y, current->thread_info.flags resides at byte offset 0 of task_struct. When a local APIC timer interrupt occurs on the same CPU while the watchpoint is armed in __tsan_memcpy, hrtimer_interrupt() -> hrtimer_interrupt_rearm() performs a marked atomic write (set_bit(TIF_HRTIMER_REARM, &current->thread_info.flags)), conflicting with the unmarked bulk read of current.

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

Root Cause Analysis

1. Mechanism & Involved Components

2. Technical Breakdown

During process creation via clone3() / copy_process(), dup_task_struct(current, node) creates a copy of the parent process's task structure by calling arch_dup_task_struct(tsk, orig). On x86 (arch/x86/kernel/process.c:108), this is implemented as:

memcpy_and_pad(dst, arch_task_struct_size, src, sizeof(*dst), 0);

where src points to the live current task (sizeof(*dst) = 3456 bytes). With CONFIG_THREAD_INFO_IN_TASK=y, current->thread_info is located at byte offset 0 of struct task_struct, with unsigned long flags at offset 0 of thread_info.

Because arch_dup_task_struct() runs with interrupts enabled, local interrupt handlers or other CPUs can concurrently modify fields in current->thread_info.flags via atomic bit operations. In the reported scenario:

  1. __tsan_memcpy (instrumenting memcpy inside memcpy_and_pad()) established a KCSAN read watchpoint covering the 3456 bytes of current (starting at offset 0, address 0xffff888101dfc500).
  2. While __tsan_memcpy was delaying in kcsan_setup_watchpoint() -> delay_access(), an APIC timer interrupt arrived on the same CPU (sysvec_apic_timer_interrupt).
  3. In interrupt context, hrtimer_interrupt() invoked hrtimer_interrupt_rearm() (kernel/time/hrtimer.c:2211), executing:
    set_thread_flag(TIF_HRTIMER_REARM);
    
    This performs an atomic bitwise write (set_bit(TIF_HRTIMER_REARM, &current_thread_info()->flags)) marked by instrument_atomic_write().
  4. KCSAN detected the collision between the marked atomic write in the IRQ handler and the unmarked bulk read in memcpy_and_pad().

3. Invariants & Lifecycle

When returning from an interrupt that interrupted kernel mode with interrupts enabled, irqentry_exit_to_kernel_mode_after_preempt() (include/linux/irq-entry-common.h:488) immediately calls:

irqentry_hrtimer_rearm_deferred() -> hrtimer_rearm_deferred() -> hrtimer_rearm_deferred_tif()

which tests and clears TIF_HRTIMER_REARM via hrtimer_test_and_clear_rearm_deferred_tif() and executes __hrtimer_rearm_deferred() before execution returns to the interrupted kernel code (memcpy_and_pad()). As a result, TIF_HRTIMER_REARM is strictly transient within the interrupt handler on return to kernel mode and is cleared before memcpy_and_pad() resumes copying.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
cc85fba0 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in hrtimer_interrupt / memcpy_and_pad 2026/11/18 06:54 2026/11/18 06:54 2026/11/18 07:00 eb4895d7
737a508a assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in hrtimer_interrupt / memcpy_and_pad 2026/11/18 06:51 2026/11/18 06:51 2026/11/18 07:33 eb4895d7

Sample crash report:
==================================================================
BUG: KCSAN: data-race in hrtimer_interrupt / memcpy_and_pad

write (marked) to 0xffff888101dfc500 of 8 bytes by interrupt on cpu 1:
 instrument_atomic_write include/linux/instrumented.h:98 [inline]
 set_bit include/asm-generic/bitops/instrumented-atomic.h:28 [inline]
 set_ti_thread_flag include/linux/thread_info.h:104 [inline]
 hrtimer_interrupt_rearm kernel/time/hrtimer.c:2211 [inline]
 hrtimer_interrupt+0x83b/0x870 kernel/time/hrtimer.c:2282
 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
 check_access kernel/kcsan/core.c:762 [inline]
 __tsan_memcpy+0x3b4/0x3c0 kernel/kcsan/core.c:1374
 memcpy_and_pad+0x48/0x80 lib/string_helpers.c:1008
 arch_dup_task_struct+0x2c/0x40 arch/x86/kernel/process.c:108
 dup_task_struct+0x6d/0x7d0 kernel/fork.c:927
 copy_process+0x570/0x2310 kernel/fork.c:2150
 kernel_clone+0x1c6/0x640 kernel/fork.c:2798
 __do_sys_clone3 kernel/fork.c:3101 [inline]
 __se_sys_clone3+0x1f5/0x230 kernel/fork.c:3080
 __x64_sys_clone3+0x31/0x40 kernel/fork.c:3080
 x64_sys_call+0x437/0x2550 arch/x86/include/generated/asm/syscalls_64.h:436
 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 to 0xffff888101dfc500 of 3456 bytes by task 3846 on cpu 1:
 memcpy_and_pad+0x48/0x80 lib/string_helpers.c:1008
 arch_dup_task_struct+0x2c/0x40 arch/x86/kernel/process.c:108
 dup_task_struct+0x6d/0x7d0 kernel/fork.c:927
 copy_process+0x570/0x2310 kernel/fork.c:2150
 kernel_clone+0x1c6/0x640 kernel/fork.c:2798
 __do_sys_clone3 kernel/fork.c:3101 [inline]
 __se_sys_clone3+0x1f5/0x230 kernel/fork.c:3080
 __x64_sys_clone3+0x31/0x40 kernel/fork.c:3080
 x64_sys_call+0x437/0x2550 arch/x86/include/generated/asm/syscalls_64.h:436
 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: 3846 Comm: syz.0.148 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:07 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in hrtimer_interrupt / memcpy_and_pad
2026/11/17 10:22 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in hrtimer_interrupt / memcpy_and_pad
2026/11/17 01:59 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in hrtimer_interrupt / memcpy_and_pad
* Struck through repros no longer work on HEAD.