aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2019-04-15 04:46:07 -0400
committerIngo Molnar <mingo@kernel.org>2019-04-16 03:42:10 -0400
commit510bb96fe5b3480b4b22d815786377e54cb701e7 (patch)
treeafdfca77448b5acac50a2fcfba1c2d2d77d6c73b
parent6a03469a1edc94da52b65478f1e00837add869a3 (diff)
x86/mm: Prevent bogus warnings with "noexec=off"
Xose Vazquez Perez reported boot warnings when NX is disabled on the kernel command line. __early_set_fixmap() triggers this warning: attempted to set unsupported pgprot: 8000000000000163 bits: 8000000000000000 supported: 7fffffffffffffff WARNING: CPU: 0 PID: 0 at arch/x86/include/asm/pgtable.h:537 __early_set_fixmap+0xa2/0xff because it uses __default_kernel_pte_mask to mask out unsupported bits. Use __supported_pte_mask instead. Disabling NX on the command line also triggers the NX warning in the page table mapping check: WARNING: CPU: 1 PID: 1 at arch/x86/mm/dump_pagetables.c:262 note_page+0x2ae/0x650 .... Make the warning depend on NX set in __supported_pte_mask. Reported-by: Xose Vazquez Perez <xose.vazquez@gmail.com> Tested-by: Xose Vazquez Perez <xose.vazquez@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@surriel.com> Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1904151037530.1729@nanos.tec.linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/mm/dump_pagetables.c3
-rw-r--r--arch/x86/mm/ioremap.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index ee8f8ab46941..c0309ea9abee 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -259,7 +259,8 @@ static void note_wx(struct pg_state *st)
259#endif 259#endif
260 /* Account the WX pages */ 260 /* Account the WX pages */
261 st->wx_pages += npages; 261 st->wx_pages += npages;
262 WARN_ONCE(1, "x86/mm: Found insecure W+X mapping at address %pS\n", 262 WARN_ONCE(__supported_pte_mask & _PAGE_NX,
263 "x86/mm: Found insecure W+X mapping at address %pS\n",
263 (void *)st->start_address); 264 (void *)st->start_address);
264} 265}
265 266
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 0029604af8a4..dd73d5d74393 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -825,7 +825,7 @@ void __init __early_set_fixmap(enum fixed_addresses idx,
825 pte = early_ioremap_pte(addr); 825 pte = early_ioremap_pte(addr);
826 826
827 /* Sanitize 'prot' against any unsupported bits: */ 827 /* Sanitize 'prot' against any unsupported bits: */
828 pgprot_val(flags) &= __default_kernel_pte_mask; 828 pgprot_val(flags) &= __supported_pte_mask;
829 829
830 if (pgprot_val(flags)) 830 if (pgprot_val(flags))
831 set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags)); 831 set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags));