]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
powerpc/ptdump: Fix W+X verification
authorChristophe Leroy <christophe.leroy@c-s.fr>
Tue, 14 Jan 2020 08:13:09 +0000 (08:13 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 13 Mar 2020 05:19:20 +0000 (01:19 -0400)
BugLink: https://bugs.launchpad.net/bugs/1867051
commit d80ae83f1f932ab7af47b54d0d3bef4f4dba489f upstream.

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: 453d87f6a8ae ("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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/mm/ptdump/ptdump.c

index 74ff2bff4ea01b9154aba21a003eb9cb7abb7ec3..18afaf663126ad3f5bba4897a124febc79c555df 100644 (file)
@@ -181,10 +181,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 (!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",