Skip to content

x86: correctly handle NX and RW bit testing

Juergen Gross lkml 1 version Applied

Status from this message: The following commit has been merged into the x86/mm branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest4 patches 0 repliesApplied

Changes in v2 from the cover letter

- split the patch into multiple patches

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/4x86/pat: introduce lookup_address_in_pgd_attr()arch/x86/include/asm/pgtable_types.h arch/x86/mm/pat/set_memory.c+32 -30 replies
2/4x86/mm: use lookup_address_in_pgd_attr() in show_fault_oops()arch/x86/mm/fault.c+4 -30 replies
3/4x86/pat: restructure _lookup_address_cpa()arch/x86/mm/pat/set_memory.c+7 -40 replies
4/4x86/pat: fix W^X violation false-positives when running as Xen PV guestarch/x86/mm/pat/set_memory.c+18 -80 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

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

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(-)
Signature · 1 line
2.35.3