linux/arch/x86/mm
Linus Torvalds 00c42373d3 x86-64: add warning for non-canonical user access address dereferences
This adds a warning (once) for any kernel dereference that has a user
exception handler, but accesses a non-canonical address.  It basically
is a simpler - and more limited - version of commit 9da3f2b740
("x86/fault: BUG() when uaccess helpers fault on kernel addresses") that
got reverted.

Note that unlike that original commit, this only causes a warning,
because there are real situations where we currently can do this
(notably speculative argument fetching for uprobes etc).  Also, unlike
that original commit, this _only_ triggers for #GP accesses, so the
cases of valid kernel pointers that cross into a non-mapped page aren't
affected.

The intent of this is two-fold:

 - the uprobe/tracing accesses really do need to be more careful. In
   particular, from a portability standpoint it's just wrong to think
   that "a pointer is a pointer", and use the same logic for any random
   pointer value you find on the stack. It may _work_ on x86-64, but it
   doesn't necessarily work on other architectures (where the same
   pointer value can be either a kernel pointer _or_ a user pointer, and
   you really need to be much more careful in how you try to access it)

   The warning can hopefully end up being a reminder that just any
   random pointer access won't do.

 - Kees in particular wanted a way to actually report invalid uses of
   wild pointers to user space accessors, instead of just silently
   failing them. Automated fuzzers want a way to get reports if the
   kernel ever uses invalid values that the fuzzer fed it.

   The non-canonical address range is a fair chunk of the address space,
   and with this you can teach syzkaller to feed in invalid pointer
   values and find cases where we do not properly validate user
   addresses (possibly due to bad uses of "set_fs()").

Acked-by: Kees Cook <keescook@chromium.org>
Cc: Jann Horn <jannh@google.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-03-04 10:08:28 -08:00
..
Makefile
amdtopology.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
cpu_entry_area.c
debug_pagetables.c x86/mm/dump_pagetables: Use DEFINE_SHOW_ATTRIBUTE() 2018-12-18 13:05:54 +01:00
dump_pagetables.c kasan: rename kasan_zero_page to kasan_early_shadow_page 2018-12-28 12:11:43 -08:00
extable.c x86-64: add warning for non-canonical user access address dereferences 2019-03-04 10:08:28 -08:00
fault.c x86/fault: Fix sign-extend unintended sign extension 2019-01-29 21:58:59 +01:00
highmem_32.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
hugetlbpage.c x86/compat: Adjust in_compat_syscall() to generic code under !COMPAT 2018-11-01 12:59:25 +01:00
ident_map.c
init.c mm: make free_reserved_area() return "const char *" 2018-12-28 12:11:48 -08:00
init_32.c mm, memory_hotplug: add nid parameter to arch_remove_memory 2018-12-28 12:11:49 -08:00
init_64.c mm, memory_hotplug: add nid parameter to arch_remove_memory 2018-12-28 12:11:49 -08:00
iomap_32.c
ioremap.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
kasan_init_64.c kasan: rename kasan_zero_page to kasan_early_shadow_page 2018-12-28 12:11:43 -08:00
kaslr.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
kmmio.c
mem_encrypt.c dma-direct: merge swiotlb_dma_ops into the dma_direct code 2018-12-13 21:06:17 +01:00
mem_encrypt_boot.S
mem_encrypt_identity.c x86/mm/mem_encrypt: Fix erroneous sizeof() 2019-01-15 11:41:58 +01:00
mm_internal.h x86/mm/cpa: Optimize cpa_flush_array() TLB invalidation 2018-12-17 18:54:26 +01:00
mmap.c x86/compat: Adjust in_compat_syscall() to generic code under !COMPAT 2018-11-01 12:59:25 +01:00
mmio-mod.c
mpx.c Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
numa.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
numa_32.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
numa_64.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
numa_emulation.c Merge branch 'core/urgent' into x86/urgent, to pick up objtool fix 2018-11-03 23:42:16 +01:00
numa_internal.h
pageattr-test.c x86/mm/cpa: Simplify the code after making cpa->vaddr invariant 2018-12-17 18:54:25 +01:00
pageattr.c x86/mm/cpa: Fix set_mce_nospec() 2019-02-08 14:31:56 +01:00
pat.c x86/mm: Fix decoy address handling vs 32-bit builds 2018-12-11 18:28:20 -08:00
pat_internal.h
pat_rbtree.c
pf_in.c
pf_in.h
pgtable.c mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
pgtable_32.c
physaddr.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
physaddr.h
pkeys.c x86/pkeys: Make init_pkru_value static 2018-12-03 19:10:18 +01:00
pti.c
setup_nx.c
srat.c
testmmiotrace.c
tlb.c x86/mm/cpa: Optimize cpa_flush_array() TLB invalidation 2018-12-17 18:54:26 +01:00