Skip to content

Commit 2150652

Browse files
amlutoIngo Molnar
authored andcommitted
x86/kasan/64: Teach KASAN about the cpu_entry_area
The cpu_entry_area will contain stacks. Make sure that KASAN has appropriate shadow mappings for them. Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Andrey Ryabinin <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Laight <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Eduardo Valentin <[email protected]> Cc: Greg KH <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent ef8813a commit 2150652

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

arch/x86/mm/kasan_init_64.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ void __init kasan_early_init(void)
277277
void __init kasan_init(void)
278278
{
279279
int i;
280+
void *shadow_cpu_entry_begin, *shadow_cpu_entry_end;
280281

281282
#ifdef CONFIG_KASAN_INLINE
282283
register_die_notifier(&kasan_die_notifier);
@@ -329,8 +330,23 @@ void __init kasan_init(void)
329330
(unsigned long)kasan_mem_to_shadow(_end),
330331
early_pfn_to_nid(__pa(_stext)));
331332

333+
shadow_cpu_entry_begin = (void *)__fix_to_virt(FIX_CPU_ENTRY_AREA_BOTTOM);
334+
shadow_cpu_entry_begin = kasan_mem_to_shadow(shadow_cpu_entry_begin);
335+
shadow_cpu_entry_begin = (void *)round_down((unsigned long)shadow_cpu_entry_begin,
336+
PAGE_SIZE);
337+
338+
shadow_cpu_entry_end = (void *)(__fix_to_virt(FIX_CPU_ENTRY_AREA_TOP) + PAGE_SIZE);
339+
shadow_cpu_entry_end = kasan_mem_to_shadow(shadow_cpu_entry_end);
340+
shadow_cpu_entry_end = (void *)round_up((unsigned long)shadow_cpu_entry_end,
341+
PAGE_SIZE);
342+
332343
kasan_populate_zero_shadow(kasan_mem_to_shadow((void *)MODULES_END),
333-
(void *)KASAN_SHADOW_END);
344+
shadow_cpu_entry_begin);
345+
346+
kasan_populate_shadow((unsigned long)shadow_cpu_entry_begin,
347+
(unsigned long)shadow_cpu_entry_end, 0);
348+
349+
kasan_populate_zero_shadow(shadow_cpu_entry_end, (void *)KASAN_SHADOW_END);
334350

335351
load_cr3(init_top_pgt);
336352
__flush_tlb_all();

0 commit comments

Comments
 (0)