KCSAN: data-race in __rcu_read_lock / memcpy_and_pad

Status: moderation: reported on 2026/11/18 00:01
Subsystems: net
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+9fffc554032b0bd68d4c@syzkaller.appspotmail.com
First crash: 22h38m, last: 22h38m
✨ AI cause bisection: introduced by (AI job) :
commit 2d299e3d773d519ee93e5aaa3ffddd4a6276b005
Author: Oleg Nesterov <oleg@redhat.com>
Date: Sat May 3 14:38:50 2025 +0000

  x86/fpu: Always use memcpy_and_pad() in arch_dup_task_struct()

  
✨ AI-generated root cause summary:

During process creation in copy_process(), dup_task_struct() calls arch_dup_task_struct() to copy the parent task's struct task_struct (current) to the child task using memcpy_and_pad() (an unmarked memcpy). Because interrupts and preemption remain enabled and the bulk copy is not annotated with data_race(), a hardirq firing on the same CPU (here, a timer interrupt executing advance_sched in net/sched/sch_taprio.c) calls rcu_read_lock() and modifies current->rcu_read_lock_nesting via rcu_preempt_read_enter() (WRITE_ONCE) while memcpy is reading current. KCSAN flags this concurrent access as a data race between __tsan_memcpy and __rcu_read_lock.

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

Technical Root Cause Analysis

1. Involved Components and Functions


2. Triggering Mechanism and Race Lifecycle

  1. Unmarked bulk copy during fork/clone: During thread/process creation via clone3() / copy_process() (kernel/fork.c:2150), dup_task_struct() allocates a new struct task_struct (tsk) and calls arch_dup_task_struct(tsk, orig) (kernel/fork.c:927), where orig is current (task 5634). On x86, arch_dup_task_struct() copies sizeof(struct task_struct) bytes (3456 bytes) using memcpy_and_pad() (arch/x86/kernel/process.c:108):

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

    This performs an unmarked bulk read via memcpy(dest, src, count) (lib/string_helpers.c:1008), instrumented by KCSAN as __tsan_memcpy(). At this point, interrupts and preemption are enabled, and the copy is not wrapped in data_race().

  2. Interrupt on the same CPU modifies current: While KCSAN delays execution in delay_access() after setting up a read watchpoint on bytes within current, a local APIC timer interrupt occurs on CPU 0 (sysvec_apic_timer_interrupt -> hrtimer_interrupt). The timer callback advance_sched() (net/sched/sch_taprio.c:1005) invokes rcu_read_lock(). Because interrupts execute in the context of the interrupted task (current), rcu_preempt_read_enter() (kernel/rcu/tree_plugin.h:389) executes:

    WRITE_ONCE(current->rcu_read_lock_nesting, READ_ONCE(current->rcu_read_lock_nesting) + 1);
    

    This performs a marked 4-byte write to current->rcu_read_lock_nesting at address 0xffff88810435a6fc (offset 0x47c of current), colliding with KCSAN's active watchpoint on 0xffff88810435a280 (orig).


3. Invariants and Correctness

  • In production kernels, this race is completely benign:
    • The interrupt executes on the same CPU, and its rcu_read_lock() is strictly balanced by rcu_read_unlock() before returning back to the interrupted task. As a result, current->rcu_read_lock_nesting is restored to its original value when returning to the copy operation.
    • While the bulk memcpy might observe a transient non-zero nesting depth written by the interrupt into the new child task struct (tsk), rcu_copy_process(tsk) (kernel/fork.c:1879, called at line 2214) unconditionally zeroes out tsk->rcu_read_lock_nesting and tsk->rcu_read_unlock_special before tsk can be made runnable or observed.
    • On any error path prior to rcu_copy_process() (such as bad_fork_free -> free_task()), rcu_read_lock_nesting is never read or evaluated.
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
c5d46623 bisect-cause ❓ KCSAN: data-race in __rcu_read_lock / memcpy_and_pad 2026/11/17 22:12 2026/11/17 22:12 2026/11/17 22:26 ca622473
83d947e1 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in __rcu_read_lock / memcpy_and_pad 2026/11/17 22:04 2026/11/17 22:04 2026/11/17 22:14 ca622473
22e54789 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in __rcu_read_lock / memcpy_and_pad 2026/11/17 21:55 2026/11/17 21:55 2026/11/17 22:29 ca622473

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

write (marked) to 0xffff88810435a6fc of 4 bytes by interrupt on cpu 0:
 rcu_preempt_read_enter kernel/rcu/tree_plugin.h:389 [inline]
 __rcu_read_lock+0x36/0x50 kernel/rcu/tree_plugin.h:412
 rcu_read_lock include/linux/rcupdate.h:847 [inline]
 advance_sched+0x6ef/0x750 net/sched/sch_taprio.c:1005
 __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
 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 0xffff88810435a280 of 3456 bytes by task 5634 on cpu 0:
 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: 0 UID: 0 PID: 5634 Comm: syz.1.5979 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

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