[PATCH v2 0/4] x86: correctly handle NX and RW bit testing

Juergen Gross posted 4 patches 1 year, 10 months ago
arch/x86/include/asm/pgtable_types.h |  2 +
arch/x86/mm/fault.c                  |  7 +--
arch/x86/mm/pat/set_memory.c         | 68 ++++++++++++++++++++++------
3 files changed, 60 insertions(+), 17 deletions(-)
[PATCH v2 0/4] x86: correctly handle NX and RW bit testing
Posted by Juergen Gross 1 year, 10 months ago
When the processor is detecting a set NX bit on any page table level
when doing a page table walk, the resulting page will not be suitable
for code execution.

A similar approach is taken for the RW bit: all page table levels need
to have the RW bit set in order to result in a writable page.

Unfortunately the kernel is only looking at the leaf page table entry
for deciding whether e.g. a writable page is executable or not.

Fix that by calculating the effective NX and RW bits over all page
table levels when doing a software address lookup, mimicking the
hardware behavior.

Changes in V2:
- split the patch into multiple patches

Juergen Gross (4):
  x86/pat: introduce lookup_address_in_pgd_attr()
  x86/mm: use lookup_address_in_pgd_attr() in show_fault_oops()
  x86/pat: restructure _lookup_address_cpa()
  x86/pat: fix W^X violation false-positives when running as Xen PV
    guest

 arch/x86/include/asm/pgtable_types.h |  2 +
 arch/x86/mm/fault.c                  |  7 +--
 arch/x86/mm/pat/set_memory.c         | 68 ++++++++++++++++++++++------
 3 files changed, 60 insertions(+), 17 deletions(-)

-- 
2.35.3