Message ID | b1177cdfc6af74a3e277bba5d9e708c4b3315ebe.1583575707.git.christophe.leroy@c-s.fr (mailing list archive) |
---|---|
State | Accepted |
Commit | cc6f0e39000900e5dd1448103a9571f0eccd7d4e |
Headers | show |
Series | powerpc/32: Fix missing NULL pmd check in virt_to_kpte() | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (ab326587bb5fb91cc97df9b9f48e9e1469f04621) |
snowpatch_ozlabs/build-ppc64le | success | Build succeeded |
snowpatch_ozlabs/build-ppc64be | success | Build succeeded |
snowpatch_ozlabs/build-ppc64e | success | Build succeeded |
snowpatch_ozlabs/build-pmac32 | success | Build succeeded |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 10 lines checked |
snowpatch_ozlabs/needsstable | success | Patch fixes a commit that hasn't been released yet |
On Sat, Mar 07, 2020 at 10:09:15AM +0000, Christophe Leroy wrote: > Commit 2efc7c085f05 ("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: 2efc7c085f05 ("powerpc/32: drop get_pteptr()") > Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> > --- > arch/powerpc/include/asm/pgtable.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h > index b80bfd41828d..b1f1d5339735 100644 > --- a/arch/powerpc/include/asm/pgtable.h > +++ b/arch/powerpc/include/asm/pgtable.h > @@ -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 > > -- > 2.25.0 > With QEMU 4.2.0, I can confirm this fixes the panic: Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Hello ppc friends, did this get picked up into -next yet? On Thu, Mar 12, 2020 at 8:35 PM Nathan Chancellor <natechancellor@gmail.com> wrote: > > On Sat, Mar 07, 2020 at 10:09:15AM +0000, Christophe Leroy wrote: > > Commit 2efc7c085f05 ("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: 2efc7c085f05 ("powerpc/32: drop get_pteptr()") > > Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> > > --- > > arch/powerpc/include/asm/pgtable.h | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h > > index b80bfd41828d..b1f1d5339735 100644 > > --- a/arch/powerpc/include/asm/pgtable.h > > +++ b/arch/powerpc/include/asm/pgtable.h > > @@ -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 > > > > -- > > 2.25.0 > > > > With QEMU 4.2.0, I can confirm this fixes the panic: > > Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Nick Desaulniers <ndesaulniers@google.com> writes: > Hello ppc friends, did this get picked up into -next yet? Not yet. It's in my next-test, but it got stuck there because some subsequent patches caused some CI errors that I had to debug. I'll push it to next today. cheers > On Thu, Mar 12, 2020 at 8:35 PM Nathan Chancellor > <natechancellor@gmail.com> wrote: >> >> On Sat, Mar 07, 2020 at 10:09:15AM +0000, Christophe Leroy wrote: >> > Commit 2efc7c085f05 ("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: 2efc7c085f05 ("powerpc/32: drop get_pteptr()") >> > Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> >> > --- >> > arch/powerpc/include/asm/pgtable.h | 4 +++- >> > 1 file changed, 3 insertions(+), 1 deletion(-) >> > >> > diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h >> > index b80bfd41828d..b1f1d5339735 100644 >> > --- a/arch/powerpc/include/asm/pgtable.h >> > +++ b/arch/powerpc/include/asm/pgtable.h >> > @@ -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 >> > >> > -- >> > 2.25.0 >> > >> >> With QEMU 4.2.0, I can confirm this fixes the panic: >> >> Tested-by: Nathan Chancellor <natechancellor@gmail.com> > > > > -- > Thanks, > ~Nick Desaulniers
On Sat, 2020-03-07 at 10:09:15 UTC, Christophe Leroy wrote: > Commit 2efc7c085f05 ("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: 2efc7c085f05 ("powerpc/32: drop get_pteptr()") > Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/cc6f0e39000900e5dd1448103a9571f0eccd7d4e cheers
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index b80bfd41828d..b1f1d5339735 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -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
Commit 2efc7c085f05 ("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: 2efc7c085f05 ("powerpc/32: drop get_pteptr()") Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> --- arch/powerpc/include/asm/pgtable.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)