Skip to content

Commit

Permalink
riscv: Fix config KASAN && SPARSEMEM && !SPARSE_VMEMMAP
Browse files Browse the repository at this point in the history
commit a3d3280 upstream.

In order to get the pfn of a struct page* when sparsemem is enabled
without vmemmap, the mem_section structures need to be initialized which
happens in sparse_init.

But kasan_early_init calls pfn_to_page way before sparse_init is called,
which then tries to dereference a null mem_section pointer.

Fix this by removing the usage of this function in kasan_early_init.

Fixes: 8ad8b72 ("riscv: Add KASAN support")
Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
AlexGhiti authored and gregkh committed Mar 8, 2022
1 parent 22db0c2 commit d1c3ac0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions arch/riscv/mm/kasan_init.c
Expand Up @@ -22,8 +22,7 @@ asmlinkage void __init kasan_early_init(void)

for (i = 0; i < PTRS_PER_PTE; ++i)
set_pte(kasan_early_shadow_pte + i,
mk_pte(virt_to_page(kasan_early_shadow_page),
PAGE_KERNEL));
pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL));

for (i = 0; i < PTRS_PER_PMD; ++i)
set_pmd(kasan_early_shadow_pmd + i,
Expand Down

0 comments on commit d1c3ac0

Please sign in to comment.