Skip to content

Commit

Permalink
powerpc/32: Fix missing NULL pmd check in virt_to_kpte()
Browse files Browse the repository at this point in the history
Commit 2efc7c0 ("powerpc/32: drop get_pteptr()"),
replaced get_pteptr() by virt_to_kpte(). But virt_to_kpte() lacks a
NULL pmd check and returns an invalid non NULL pointer when there
is no page table.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Fixes: 2efc7c0 ("powerpc/32: drop get_pteptr()")
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/b1177cdfc6af74a3e277bba5d9e708c4b3315ebe.1583575707.git.christophe.leroy@c-s.fr
  • Loading branch information
Christophe Leroy authored and Michael Ellerman committed Mar 13, 2020
1 parent 819723a commit cc6f0e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/powerpc/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ static inline pmd_t *pmd_ptr_k(unsigned long va)

static inline pte_t *virt_to_kpte(unsigned long vaddr)
{
return pte_offset_kernel(pmd_ptr_k(vaddr), vaddr);
pmd_t *pmd = pmd_ptr_k(vaddr);

return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
}
#endif

Expand Down

0 comments on commit cc6f0e3

Please sign in to comment.