alistair23-linux/arch/x86/mm
Stephen Smalley e1a58320a3 x86/mm: Warn on W^X mappings
Warn on any residual W+X mappings after setting NX
if DEBUG_WX is enabled.  Introduce a separate
X86_PTDUMP_CORE config that enables the code for
dumping the page tables without enabling the debugfs
interface, so that DEBUG_WX can be enabled without
exposing the debugfs interface.  Switch EFI_PGT_DUMP
to using X86_PTDUMP_CORE so that it also does not require
enabling the debugfs interface.

On success it prints this to the kernel log:

  x86/mm: Checked W+X mappings: passed, no W+X pages found.

On failure it prints a warning and a count of the failed pages:

  ------------[ cut here ]------------
  WARNING: CPU: 1 PID: 1 at arch/x86/mm/dump_pagetables.c:226 note_page+0x610/0x7b0()
  x86/mm: Found insecure W+X mapping at address ffffffff81755000/__stop___ex_table+0xfa8/0xabfa8
  [...]
  Call Trace:
   [<ffffffff81380a5f>] dump_stack+0x44/0x55
   [<ffffffff8109d3f2>] warn_slowpath_common+0x82/0xc0
   [<ffffffff8109d48c>] warn_slowpath_fmt+0x5c/0x80
   [<ffffffff8106cfc9>] ? note_page+0x5c9/0x7b0
   [<ffffffff8106d010>] note_page+0x610/0x7b0
   [<ffffffff8106d409>] ptdump_walk_pgd_level_core+0x259/0x3c0
   [<ffffffff8106d5a7>] ptdump_walk_pgd_level_checkwx+0x17/0x20
   [<ffffffff81063905>] mark_rodata_ro+0xf5/0x100
   [<ffffffff817415a0>] ? rest_init+0x80/0x80
   [<ffffffff817415bd>] kernel_init+0x1d/0xe0
   [<ffffffff8174cd1f>] ret_from_fork+0x3f/0x70
   [<ffffffff817415a0>] ? rest_init+0x80/0x80
  ---[ end trace a1f23a1e42a2ac76 ]---
  x86/mm: Checked W+X mappings: FAILED, 171 W+X pages found.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1444064120-11450-1-git-send-email-sds@tycho.nsa.gov
[ Improved the Kconfig help text and made the new option default-y
  if CONFIG_DEBUG_RODATA=y, because it already found buggy mappings,
  so we really want people to have this on by default. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-10-06 11:11:48 +02:00
..
kmemcheck
amdtopology.c
dump_pagetables.c x86/mm: Warn on W^X mappings 2015-10-06 11:11:48 +02:00
extable.c
fault.c x86/vm86: Clean up vm86.h includes 2015-07-31 13:31:10 +02:00
gup.c x86/mm: Fix gup_huge_p?d() to handle large PAT bit 2015-09-22 21:27:33 +02:00
highmem_32.c
hugetlbpage.c
init.c x86/mm/pat: Add comments to cachemode translation tables 2015-08-20 21:26:12 +02:00
init_32.c x86/mm: Warn on W^X mappings 2015-10-06 11:11:48 +02:00
init_64.c x86/mm: Warn on W^X mappings 2015-10-06 11:11:48 +02:00
iomap_32.c Merge branch 'x86-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-06-22 17:59:09 -07:00
ioremap.c x86/mm: Fix newly introduced printk format warnings 2015-07-24 16:35:33 +02:00
kasan_init_64.c x86/kasan, mm: Introduce generic kasan_populate_zero_shadow() 2015-08-22 14:54:55 +02:00
kmmio.c
Makefile x86/mm: Warn on W^X mappings 2015-10-06 11:11:48 +02:00
mm_internal.h
mmap.c x86/mpx: Do not set ->vm_ops on MPX VMAs 2015-07-21 07:57:16 +02:00
mmio-mod.c
mpx.c mm, mpx: add "vm_flags_t vm_flags" arg to do_mmap_pgoff() 2015-09-10 13:29:01 -07:00
numa.c mem-hotplug: handle node hole when initializing numa_meminfo. 2015-09-08 15:35:28 -07:00
numa_32.c
numa_64.c
numa_emulation.c
numa_internal.h
pageattr-test.c x86/mm/pat: Make mm/pageattr[-test].c explicitly non-modular 2015-08-25 09:48:38 +02:00
pageattr.c x86/mm: Fix no-change case in try_preserve_large_page() 2015-09-22 21:27:33 +02:00
pat.c
pat_internal.h
pat_rbtree.c
pf_in.c
pf_in.h
pgtable.c
pgtable_32.c
physaddr.c
physaddr.h
setup_nx.c
srat.c x86/mm/srat: Print non-volatile flag in SRAT 2015-09-02 09:33:25 +02:00
testmmiotrace.c
tlb.c x86, mm: trace when an IPI is about to be sent 2015-09-04 16:54:41 -07:00