summaryrefslogtreecommitdiff
path: root/scripts/Makefile.thinlto
diff options
context:
space:
mode:
authorMarco Elver <elver@google.com>2026-10-30 00:46:03 +0000
committerMarco Elver <elver@google.com>2026-11-03 13:53:22 +0000
commit880748cd41fc7c7ca112bbd509d050f68466b88a (patch)
treefe6d2adefe31b5f5bfd1dcbd25ce18f50977783b /scripts/Makefile.thinlto
parent6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 (diff)
downloadlinux-next-880748cd41fc7c7ca112bbd509d050f68466b88a.tar.gz
linux-next-880748cd41fc7c7ca112bbd509d050f68466b88a.zip
kcsan: Reset per-task KCSAN state on fork
arch_dup_task_struct() copies the parent's task_struct verbatim, which includes kcsan_ctx and kcsan_stack_depth; nothing reinitializes them for the child. With CONFIG_KCSAN_WEAK_MEMORY this leaks a live reorder_access: an access whose simulated reordering is only valid until the parent returns from the frame that performed it (tracked via kcsan_stack_depth and cleared by __tsan_func_exit()). The child inherits both the entry and the parent's stack depth, but never returns through the parent's frames, so the entry is never invalidated and is replayed on every subsequent check_access() of the child. The most direct way to hit this is the copy itself: __tsan_memcpy() runs check_access() on the destination before copying. If that access is selected for a watchpoint, set_reorder_access() records it (ptr = the child's task_struct, ip in arch_dup_task_struct()) in the parent's ctx, and the memcpy then copies that entry into the child. For an idle task created by fork_idle(), the stale access covers thread_info.flags, which other CPUs frequently access, resulting in false positive reports and: WARNING: kernel/kcsan/report.c:344 at sanitize_stack_entries+0x120/0x12c Cannot find frame for arch_dup_task_struct+0x40/0x154 in stack trace ... Call trace: sanitize_stack_entries+0x120/0x12c (P) print_report+0x84/0x488 kcsan_report_known_origin+0x14c/0x1ec kcsan_setup_watchpoint+0x578/0x864 __kcsan_check_access+0x1ec/0x1f8 do_raw_spin_lock+0xa4/0x1c4 _raw_spin_lock+0x70/0x88 rcutree_report_cpu_starting+0x1ac/0x4b8 secondary_start_kernel+0xe8/0x28c __secondary_switched+0xc0/0xc4 Reset the child's KCSAN state in dup_task_struct() after the copy, alongside the existing kcov/kmsan initializers. Reported-by: Paul E. McKenney <paulmck@kernel.org> Tested-by: Paul E. McKenney <paulmck@kernel.org> Link: https://lore.kernel.org/all/97f6213a-1dec-494e-96d1-abe546bce993@paulmck-laptop/ Fixes: 69562e4983d9 ("kcsan: Add core support for a subset of weak memory modeling") Cc: stable@vger.kernel.org Signed-off-by: Marco Elver <elver@google.com>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions