aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2018-10-08 15:53:48 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-10-10 09:16:13 -0400
commitc200dac78fec66d87ef262cac38cfe4feabdf737 (patch)
treed9893837b598939b240f23b17f927c289bb065fc
parentb69c2e20f6e4046da84ce5b33ba1ef89cb087b40 (diff)
x86/mm: Do not warn about PCI BIOS W+X mappings
PCI BIOS requires the BIOS area 0x0A0000-0x0FFFFFF to be mapped W+X for various legacy reasons. When CONFIG_DEBUG_WX is enabled, this triggers the WX warning, but this is misleading because the mapping is required and is not a result of an accidental oversight. Prevent the full warning when PCI BIOS is enabled and the detected WX mapping is in the BIOS area. Just emit a pr_warn() which denotes the fact. This is partially duplicating the info which the PCI BIOS code emits when it maps the area as executable, but that info is not in the context of the WX checking output. Remove the extra %p printout in the WARN_ONCE() while at it. %pS is enough. Reported-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Borislav Petkov <bp@suse.de> Cc: Joerg Roedel <joro@8bytes.org> Cc: Kees Cook <keescook@chromium.org> Cc: Bjorn Helgaas <bhelgaas@google.com> Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1810082151160.2455@nanos.tec.linutronix.de
-rw-r--r--arch/x86/mm/dump_pagetables.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index a12afff146d1..fc37bbd23eb8 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -19,7 +19,9 @@
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/seq_file.h> 20#include <linux/seq_file.h>
21#include <linux/highmem.h> 21#include <linux/highmem.h>
22#include <linux/pci.h>
22 23
24#include <asm/e820/types.h>
23#include <asm/pgtable.h> 25#include <asm/pgtable.h>
24 26
25/* 27/*
@@ -241,6 +243,29 @@ static unsigned long normalize_addr(unsigned long u)
241 return (signed long)(u << shift) >> shift; 243 return (signed long)(u << shift) >> shift;
242} 244}
243 245
246static void note_wx(struct pg_state *st)
247{
248 unsigned long npages;
249
250 npages = (st->current_address - st->start_address) / PAGE_SIZE;
251
252#ifdef CONFIG_PCI_BIOS
253 /*
254 * If PCI BIOS is enabled, the PCI BIOS area is forced to WX.
255 * Inform about it, but avoid the warning.
256 */
257 if (pcibios_enabled && st->start_address >= PAGE_OFFSET + BIOS_BEGIN &&
258 st->current_address <= PAGE_OFFSET + BIOS_END) {
259 pr_warn_once("x86/mm: PCI BIOS W+X mapping %lu pages\n", npages);
260 return;
261 }
262#endif
263 /* Account the WX pages */
264 st->wx_pages += npages;
265 WARN_ONCE(1, "x86/mm: Found insecure W+X mapping at address %pS\n",
266 (void *)st->start_address);
267}
268
244/* 269/*
245 * This function gets called on a break in a continuous series 270 * This function gets called on a break in a continuous series
246 * of PTE entries; the next one is different so we need to 271 * of PTE entries; the next one is different so we need to
@@ -276,14 +301,8 @@ static void note_page(struct seq_file *m, struct pg_state *st,
276 unsigned long delta; 301 unsigned long delta;
277 int width = sizeof(unsigned long) * 2; 302 int width = sizeof(unsigned long) * 2;
278 303
279 if (st->check_wx && (eff & _PAGE_RW) && !(eff & _PAGE_NX)) { 304 if (st->check_wx && (eff & _PAGE_RW) && !(eff & _PAGE_NX))
280 WARN_ONCE(1, 305 note_wx(st);
281 "x86/mm: Found insecure W+X mapping at address %p/%pS\n",
282 (void *)st->start_address,
283 (void *)st->start_address);
284 st->wx_pages += (st->current_address -
285 st->start_address) / PAGE_SIZE;
286 }
287 306
288 /* 307 /*
289 * Now print the actual finished series 308 * Now print the actual finished series