Skip to content

Commit

Permalink
powerpc/ptdump: Fix W+X verification
Browse files Browse the repository at this point in the history
Verification cannot rely on simple bit checking because on some
platforms PAGE_RW is 0, checking that a page is not W means
checking that PAGE_RO is set instead of checking that PAGE_RW
is not set.

Use pte helpers instead of checking bits.

Fixes: 453d87f ("powerpc/mm: Warn if W+X pages found on boot")
Cc: stable@vger.kernel.org # v5.2+
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/0d894839fdbb19070f0e1e4140363be4f2bb62fc.1578989540.git.christophe.leroy@c-s.fr
  • Loading branch information
Christophe Leroy authored and Michael Ellerman committed Jan 23, 2020
1 parent e26ad93 commit d80ae83
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/powerpc/mm/ptdump/ptdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ static void dump_addr(struct pg_state *st, unsigned long addr)

static void note_prot_wx(struct pg_state *st, unsigned long addr)
{
pte_t pte = __pte(st->current_flags);

if (!IS_ENABLED(CONFIG_PPC_DEBUG_WX) || !st->check_wx)
return;

if (!((st->current_flags & pgprot_val(PAGE_KERNEL_X)) == pgprot_val(PAGE_KERNEL_X)))
if (!pte_write(pte) || !pte_exec(pte))
return;

WARN_ONCE(1, "powerpc/mm: Found insecure W+X mapping at address %p/%pS\n",
Expand Down

0 comments on commit d80ae83

Please sign in to comment.