提交 cc6f0e39 编写于 作者: C Christophe Leroy 提交者: Michael Ellerman

powerpc/32: Fix missing NULL pmd check in virt_to_kpte()

Commit 2efc7c08 ("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: NNick Desaulniers <ndesaulniers@google.com>
Fixes: 2efc7c08 ("powerpc/32: drop get_pteptr()")
Signed-off-by: NChristophe Leroy <christophe.leroy@c-s.fr>
Tested-by: NNathan Chancellor <natechancellor@gmail.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/b1177cdfc6af74a3e277bba5d9e708c4b3315ebe.1583575707.git.christophe.leroy@c-s.fr
上级 819723a8
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册