Technical Summary and Root Cause Analysis
1. Mechanism and Call Flow
The bug report is a KCSAN data race detected on current->migration_disabled (a 2-byte unsigned short field in struct task_struct, here at address 0xffff8881046d0478) occurring entirely on the same CPU (CPU 0) between process context and an interrupt/softirq context.
The two racing sides operate as follows:
-
Process Context (Reader):
-
Softirq Context (Writer):
2. Root Cause
-
Inlining of Scheduler Migration Helpers:
Previously, migrate_disable() and migrate_enable() were implemented as out-of-line functions in kernel/sched/core.c. In kernel/sched/Makefile, KCSAN instrumentation is explicitly disabled (KCSAN_SANITIZE := n). Commit 378b7708194f ("sched: Make migrate_{en,dis}able() inline") moved __migrate_disable() and __migrate_enable() into include/linux/sched.h as static inline functions so they could be inlined at call sites to reduce BPF trampoline overhead. This exposed plain C loads and stores of p->migration_disabled to KCSAN instrumentation across arbitrary subsystems (filter.h, af_packet.c, flow_dissector.c, etc.).
-
Interrupt / Softirq Reentrancy on current->migration_disabled:
BPF execution helpers like bpf_prog_run_pin_on_cpu() and bpf_prog_run_clear_cb() wrap BPF executions in migrate_disable() / migrate_enable(). While this is necessary for migratable/preemptible contexts (such as PREEMPT_RT or preemptible process context under rcu_read_lock()), these functions are also called in non-threaded softirq context (NET_RX_SOFTIRQ), where preemption and migration are already disabled. When invoked in softirq on !PREEMPT_RT, current remains the interrupted task, and __migrate_disable() / __migrate_enable() manipulate current->migration_disabled without annotations (READ_ONCE()/WRITE_ONCE(), data_race(), or __no_kcsan) or local interrupt disablement.