Skip to content

Commit c5129ec

Browse files
committed
x86/mm: Ease W^X enforcement back to just a warning
Currently, the "change_page_attr" (CPA) code refuses to create W+X mappings on 64-bit kernels. There have been reports both from 32-bit[1] and from BPF[2] users where this change kept the system from booting. These reports are showing up even after about a month of soak time in -next. To avoid breaking anything, never enforce W^X. Always warn and return the requested permissions even if a problem is detected. 1. https://lore.kernel.org/all/CAMj1kXHcF_iK_g0OZSkSv56Wmr=eQGQwNstcNjLEfS=mm7a06w@mail.gmail.com/ 2. https://lore.kernel.org/bpf/[email protected]/T/#u Signed-off-by: Dave Hansen <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: [email protected] Cc: "H. Peter Anvin" <[email protected]> Cc: Kees Cook <[email protected]> Cc: Peter Zijlstra <[email protected]>
1 parent 8c4934f commit c5129ec

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

arch/x86/mm/pat/set_memory.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long start,
580580
}
581581

582582
/*
583-
* Validate and enforce strict W^X semantics.
583+
* Validate strict W^X semantics.
584584
*/
585585
static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long start,
586586
unsigned long pfn, unsigned long npg)
@@ -595,7 +595,7 @@ static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long star
595595
if (IS_ENABLED(CONFIG_X86_32))
596596
return new;
597597

598-
/* Only enforce when NX is supported: */
598+
/* Only verify when NX is supported: */
599599
if (!(__supported_pte_mask & _PAGE_NX))
600600
return new;
601601

@@ -606,13 +606,17 @@ static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long star
606606
return new;
607607

608608
end = start + npg * PAGE_SIZE - 1;
609-
WARN_ONCE(1, "CPA refuse W^X violation: %016llx -> %016llx range: 0x%016lx - 0x%016lx PFN %lx\n",
609+
WARN_ONCE(1, "CPA detected W^X violation: %016llx -> %016llx range: 0x%016lx - 0x%016lx PFN %lx\n",
610610
(unsigned long long)pgprot_val(old),
611611
(unsigned long long)pgprot_val(new),
612612
start, end, pfn);
613613

614-
/* refuse the transition into WX */
615-
return old;
614+
/*
615+
* For now, allow all permission change attempts by returning the
616+
* attempted permissions. This can 'return old' to actively
617+
* refuse the permission change at a later time.
618+
*/
619+
return new;
616620
}
617621

618622
/*

0 commit comments

Comments
 (0)