Skip to content

Commit f75c235

Browse files
SiFiveHollandctmarinas
authored andcommitted
arm64: Fix KASAN random tag seed initialization
Currently, kasan_init_sw_tags() is called before setup_per_cpu_areas(), so per_cpu(prng_state, cpu) accesses the same address regardless of the value of "cpu", and the same seed value gets copied to the percpu area for every CPU. Fix this by moving the call to smp_prepare_boot_cpu(), which is the first architecture hook after setup_per_cpu_areas(). Fixes: 3c9e3aa ("kasan: add tag related helper functions") Fixes: 3f41b60 ("kasan: fix random seed generation for tag-based mode") Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrey Konovalov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent a21dcf0 commit f75c235

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

arch/arm64/kernel/setup.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,6 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)
355355
smp_init_cpus();
356356
smp_build_mpidr_hash();
357357

358-
/* Init percpu seeds for random tags after cpus are set up. */
359-
kasan_init_sw_tags();
360-
361358
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
362359
/*
363360
* Make sure init_thread_info.ttbr0 always generates translation

arch/arm64/kernel/smp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ void __init smp_prepare_boot_cpu(void)
467467
init_gic_priority_masking();
468468

469469
kasan_init_hw_tags();
470+
/* Init percpu seeds for random tags after cpus are set up. */
471+
kasan_init_sw_tags();
470472
}
471473

472474
/*

0 commit comments

Comments
 (0)