Skip to content

Commit ca47d0b

Browse files
pvts-matPlaidCat
authored andcommitted
x86/mm: Do not shuffle CPU entry areas without KASLR
jira VULN-3958 cve-bf CVE-2023-0597 commit-author Michal Koutný <[email protected]> commit a3f547a The commit 97e3d26 ("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 3f148f3 ("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: 97e3d26 ("x86/mm: Randomize per-cpu entry area") Signed-off-by: Michal Koutný <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/20230306193144.24605-1-mkoutny%40suse.com (cherry picked from commit a3f547a) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent 1b500e0 commit ca47d0b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/x86/mm/cpu_entry_area.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <asm/fixmap.h>
1212
#include <asm/desc.h>
1313
#include <asm/kasan.h>
14+
#include <asm/setup.h>
1415

1516
static DEFINE_PER_CPU_PAGE_ALIGNED(struct entry_stack_page, entry_stack_storage);
1617

@@ -30,6 +31,12 @@ static __init void init_cea_offsets(void)
3031
unsigned int max_cea;
3132
unsigned int i, j;
3233

34+
if (!kaslr_enabled()) {
35+
for_each_possible_cpu(i)
36+
per_cpu(_cea_offset, i) = i;
37+
return;
38+
}
39+
3340
max_cea = (CPU_ENTRY_AREA_MAP_SIZE - PAGE_SIZE) / CPU_ENTRY_AREA_SIZE;
3441

3542
/* O(sodding terrible) */

0 commit comments

Comments
 (0)