mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] x86: correctly handle NX and RW bit testing
@ 2024-04-12 15:12 Juergen Gross
  2024-04-12 15:12 ` [PATCH v2 1/4] x86/pat: introduce lookup_address_in_pgd_attr() Juergen Gross
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Juergen Gross @ 2024-04-12 15:12 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: Juergen Gross, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin, Andy Lutomirski, Peter Zijlstra

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-14 20:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-12 15:12 [PATCH v2 0/4] x86: correctly handle NX and RW bit testing Juergen Gross
2024-04-12 15:12 ` [PATCH v2 1/4] x86/pat: introduce lookup_address_in_pgd_attr() Juergen Gross
2024-04-14 20:31   ` [tip: x86/mm] x86/pat: Introduce lookup_address_in_pgd_attr() tip-bot2 for Juergen Gross
2024-04-12 15:12 ` [PATCH v2 2/4] x86/mm: use lookup_address_in_pgd_attr() in show_fault_oops() Juergen Gross
2024-04-14 20:31   ` [tip: x86/mm] x86/mm: Use " tip-bot2 for Juergen Gross
2024-04-12 15:12 ` [PATCH v2 3/4] x86/pat: restructure _lookup_address_cpa() Juergen Gross
2024-04-14 20:31   ` [tip: x86/mm] x86/pat: Restructure _lookup_address_cpa() tip-bot2 for Juergen Gross
2024-04-12 15:12 ` [PATCH v2 4/4] x86/pat: fix W^X violation false-positives when running as Xen PV guest Juergen Gross
2024-04-14 20:30   ` [tip: x86/mm] x86/pat: Fix " tip-bot2 for Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®