syzbot
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: 22h32m, last: 22h32m
✨ 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
Technical Root Cause Analysis
1. Involved Components and Functions
- Source Files:
- Structs and Fields:
struct task_struct::rcu_read_lock_nesting (offset 0x47c / byte 1148 on x86-64 under CONFIG_PREEMPT_RCU)
2. Triggering Mechanism and Race Lifecycle
-
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().
-
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.
Sample crash report:
* Struck through repros no longer work on HEAD.