Skip to content

Commit

Permalink
powerpc64/kasan: Pass virtual addresses to kasan_init_phys_region()
Browse files Browse the repository at this point in the history
The kasan_init_phys_region() function maps shadow pages necessary for
the ranges of the linear map backed by physical pages. Currently
kasan_init_phys_region() is being passed physical addresses, but
kasan_mem_to_shadow() expects virtual addresses.

It works right now because the lower bits (12:64) of the
kasan_mem_to_shadow() calculation are the same for the real and virtual
addresses, so the actual PTE value is the same in the end. But virtual
addresses are the intended input, so fix it.

Signed-off-by: Benjamin Gray <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://msgid.link/[email protected]
  • Loading branch information
BenjaminGrayNp1 authored and mpe committed May 7, 2024
1 parent ad67971 commit 295454e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/mm/kasan/init_book3e_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void __init kasan_init(void)
pte_t zero_pte = pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL_RO);

for_each_mem_range(i, &start, &end)
kasan_init_phys_region((void *)start, (void *)end);
kasan_init_phys_region(phys_to_virt(start), phys_to_virt(end));

if (IS_ENABLED(CONFIG_KASAN_VMALLOC))
kasan_remove_zero_shadow((void *)VMALLOC_START, VMALLOC_SIZE);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/mm/kasan/init_book3s_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void __init kasan_init(void)
}

for_each_mem_range(i, &start, &end)
kasan_init_phys_region((void *)start, (void *)end);
kasan_init_phys_region(phys_to_virt(start), phys_to_virt(end));

for (i = 0; i < PTRS_PER_PTE; i++)
__set_pte_at(&init_mm, (unsigned long)kasan_early_shadow_page,
Expand Down

0 comments on commit 295454e

Please sign in to comment.