1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/arch/powerpc/include/asm/nohash/32
Christophe Leroy b6cb20fdc2 powerpc/book3e: Fix set_memory_x() and set_memory_nx()
set_memory_x() calls pte_mkexec() which sets _PAGE_EXEC.
set_memory_nx() calls pte_exprotec() which clears _PAGE_EXEC.

Book3e has 2 bits, UX and SX, which defines the exec rights
resp. for user (PR=1) and for kernel (PR=0).

_PAGE_EXEC is defined as UX only.

An executable kernel page is set with either _PAGE_KERNEL_RWX
or _PAGE_KERNEL_ROX, which both have SX set and UX cleared.

So set_memory_nx() call for an executable kernel page does
nothing because UX is already cleared.

And set_memory_x() on a non-executable kernel page makes it
executable for the user and keeps it non-executable for kernel.

Also, pte_exec() always returns 'false' on kernel pages, because
it checks _PAGE_EXEC which doesn't include SX, so for instance
the W+X check doesn't work.

To fix this:
  - change tlb_low_64e.S to use _PAGE_BAP_UX instead of _PAGE_USER
  - sets both UX and SX in _PAGE_EXEC so that pte_exec() returns
    true whenever one of the two bits is set and pte_exprotect()
    clears both bits.
  - Define a book3e specific version of pte_mkexec() which sets
    either SX or UX based on UR.

Fixes: 1f9ad21c3b ("powerpc/mm: Implement set_memory() routines")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/c41100f9c144dc5b62e5a751b810190c6b5d42fd.1635226743.git.christophe.leroy@csgroup.eu
2021-10-28 00:41:29 +11:00
..
hugetlb-8xx.h mm/hugetlb: change parameters of arch_make_huge_pte() 2021-06-30 20:47:26 -07:00
kup-8xx.h powerpc/kuap: Remove to/from/size parameters of prevent_user_access() 2021-06-17 00:09:09 +10:00
mmu-8xx.h powerpc/8xx: add support for huge pages on VMAP and VMALLOC 2021-06-30 20:47:26 -07:00
mmu-40x.h powerpc/vdso: Replace vdso_base by vdso 2020-12-04 01:01:16 +11:00
mmu-44x.h powerpc/44x: Implement Kernel Userspace Exec Protection (KUEP) 2021-06-17 00:09:07 +10:00
pgalloc.h powerpc/mm: refactor pgd_alloc() and pgd_free() on nohash 2019-05-03 01:20:25 +10:00
pgtable.h powerpc/book3e: Fix set_memory_x() and set_memory_nx() 2021-10-28 00:41:29 +11:00
pte-8xx.h powerpc/nohash: Fix __ptep_set_access_flags() and ptep_set_wrprotect() 2021-10-28 00:41:28 +11:00
pte-40x.h powerpc/40x: Rework 40x PTE access and TLB miss 2020-05-28 23:24:34 +10:00
pte-44x.h powerpc/mm: Make pte_pgprot return all pte bits 2018-10-19 00:56:17 +11:00
pte-fsl-booke.h powerpc/mm: Make pte_pgprot return all pte bits 2018-10-19 00:56:17 +11:00