linux/mm
Tavis Ormandy c11470084f install_special_mapping skips security_file_mmap check.
commit 462e635e5b upstream.

The install_special_mapping routine (used, for example, to setup the
vdso) skips the security check before insert_vm_struct, allowing a local
attacker to bypass the mmap_min_addr security restriction by limiting
the available pages for special mappings.

bprm_mm_init() also skips the check, and although I don't think this can
be used to bypass any restrictions, I don't see any reason not to have
the security check.

  $ uname -m
  x86_64
  $ cat /proc/sys/vm/mmap_min_addr
  65536
  $ cat install_special_mapping.s
  section .bss
      resb BSS_SIZE
  section .text
      global _start
      _start:
          mov     eax, __NR_pause
          int     0x80
  $ nasm -D__NR_pause=29 -DBSS_SIZE=0xfffed000 -f elf -o install_special_mapping.o install_special_mapping.s
  $ ld -m elf_i386 -Ttext=0x10000 -Tbss=0x11000 -o install_special_mapping install_special_mapping.o
  $ ./install_special_mapping &
  [1] 14303
  $ cat /proc/14303/maps
  0000f000-00010000 r-xp 00000000 00:00 0                                  [vdso]
  00010000-00011000 r-xp 00001000 00:19 2453665                            /home/taviso/install_special_mapping
  00011000-ffffe000 rwxp 00000000 00:00 0                                  [stack]

It's worth noting that Red Hat are shipping with mmap_min_addr set to
4096.

Signed-off-by: Tavis Ormandy <taviso@google.com>
Acked-by: Kees Cook <kees@ubuntu.com>
Acked-by: Robert Swiecki <swiecki@google.com>
[ Changed to not drop the error code - akpm ]
Reviewed-by: James Morris <jmorris@namei.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-01-07 13:58:35 -08:00
..
backing-dev.c bdi: Initialize noop_backing_dev_info properly 2010-09-22 09:48:47 +02:00
bootmem.c
bounce.c bounce: call flush_dcache_page() after bounce_copy_vec() 2010-09-09 18:57:25 -07:00
compaction.c mm: compaction: handle active and inactive fairly in too_many_isolated 2010-09-09 18:57:24 -07:00
debug-pagealloc.c
dmapool.c
fadvise.c
failslab.c
filemap_xip.c
filemap.c mm/vfs: revalidate page->mapping in do_generic_file_read() 2010-12-09 13:32:53 -08:00
fremap.c Avoid pgoff overflow in remap_file_pages 2010-09-25 09:34:58 -07:00
highmem.c
hugetlb.c mm/hugetlb.c: avoid double unlock_page() in hugetlb_fault() 2010-12-09 13:33:15 -08:00
hwpoison-inject.c
init-mm.c
internal.h mm: fix is_mem_section_removable() page_order BUG_ON check 2010-12-09 13:32:34 -08:00
Kconfig mm: avoid warning when COMPACTION is selected 2010-09-09 18:57:24 -07:00
Kconfig.debug
kmemcheck.c
kmemleak-test.c
kmemleak.c
ksm.c ksm: fix bad user data when swapping 2010-10-04 11:09:53 -07:00
maccess.c
madvise.c
Makefile
memblock.c
memcontrol.c memcg: avoid deadlock between move charge and try_charge() 2010-12-09 13:33:22 -08:00
memory_hotplug.c mm: fix return value of scan_lru_pages in memory unplug 2010-12-09 13:32:34 -08:00
memory-failure.c HWPOISON: Stop shrinking at right page count 2010-10-07 09:47:10 +02:00
memory.c mm: further fix swapin race condition 2010-09-20 10:44:37 -07:00
mempolicy.c numa: fix slab_node(MPOL_BIND) 2010-12-09 13:32:32 -08:00
mempool.c
migrate.c
mincore.c
mlock.c mm: Move vma_stack_continue into mm.h 2010-09-09 09:05:06 -07:00
mm_init.c
mmap.c install_special_mapping skips security_file_mmap check. 2011-01-07 13:58:35 -08:00
mmu_context.c
mmu_notifier.c
mmzone.c mm: page allocator: calculate a better estimate of NR_FREE_PAGES when memory is low and kswapd is awake 2010-09-09 18:57:25 -07:00
mprotect.c perf_events: Fix perf_counter_mmap() hook in mprotect() 2010-12-09 13:33:19 -08:00
mremap.c
msync.c
nommu.c nommu: yield CPU while disposing VM 2010-12-09 13:33:17 -08:00
oom_kill.c oom: filter unkillable tasks from tasklist dump 2010-09-22 17:22:39 -07:00
page_alloc.c PM / Hibernate: Fix memory corruption related to swap 2010-12-09 13:33:26 -08:00
page_cgroup.c
page_io.c
page_isolation.c
page-writeback.c
pagewalk.c
percpu_up.c
percpu-km.c
percpu-vm.c
percpu.c percpu: fix pcpu_last_unit_cpu 2010-09-21 08:12:25 +02:00
prio_tree.c
quicklist.c
readahead.c
rmap.c ksm: fix page_address_in_vma anon_vma oops 2010-10-04 11:09:53 -07:00
shmem.c
slab.c
slob.c
slub.c
sparse-vmemmap.c
sparse.c
swap_state.c
swap.c
swapfile.c swap: discard while swapping only if SWAP_FLAG_DISCARD 2010-09-09 18:57:25 -07:00
thrash.c
truncate.c
util.c
vmalloc.c mm, x86: Saving vmcore with non-lazy freeing of vmas 2010-11-22 11:03:03 -08:00
vmscan.c vmscan: check all_unreclaimable in direct reclaim path 2010-09-22 17:22:39 -07:00
vmstat.c mm: page allocator: calculate a better estimate of NR_FREE_PAGES when memory is low and kswapd is awake 2010-09-09 18:57:25 -07:00