x86/mm: Do not shuffle CPU entry areas without KASLR
authorMichal Koutný <mkoutny@suse.com>
Mon, 6 Mar 2023 19:31:44 +0000 (20:31 +0100)
committerDave Hansen <dave.hansen@linux.intel.com>
Wed, 22 Mar 2023 17:42:47 +0000 (10:42 -0700)
commita3f547addcaa10df5a226526bc9e2d9a94542344
tree94654c004b82a932ea4a5348fd545d6008e13182
parentcbebd68f59f03633469f3ecf9bea99cd6cce3854
x86/mm: Do not shuffle CPU entry areas without KASLR

The commit 97e3d26b5e5f ("x86/mm: Randomize per-cpu entry area") fixed
an omission of KASLR on CPU entry areas. It doesn't take into account
KASLR switches though, which may result in unintended non-determinism
when a user wants to avoid it (e.g. debugging, benchmarking).

Generate only a single combination of CPU entry areas offsets -- the
linear array that existed prior randomization when KASLR is turned off.

Since we have 3f148f331814 ("x86/kasan: Map shadow for percpu pages on
demand") and followups, we can use the more relaxed guard
kasrl_enabled() (in contrast to kaslr_memory_enabled()).

Fixes: 97e3d26b5e5f ("x86/mm: Randomize per-cpu entry area")
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20230306193144.24605-1-mkoutny%40suse.com
arch/x86/mm/cpu_entry_area.c