Make adjustments to how MAP_STACK works to prevent improper mmap()s.
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 23 Apr 2009 21:41:28 +0000 (14:41 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 23 Apr 2009 21:41:28 +0000 (14:41 -0700)
commitc809941bd5d72ef4ef4ef648c0fba8946b9e61e3
treea12a274424c19d64685c62ee59b074c6876198a5
parent2035b67992ac162a5968a22584ef29d2f53f93e2
Make adjustments to how MAP_STACK works to prevent improper mmap()s.

Record that a vm_map_entry is a stack mapping.  When locating free space
do not allow non-MAP_STACK mappings to use space reserved by MAP_STACK
mappings, unless MAP_FIXED is used of course.

Previously MAP_STACK mappings implied MAP_FIXED, which is not how they are
supposed to work.  Implement proper hinting without MAP_FIXED.

Do not allow a normal mmap() call to use space reserved by a MAP_STACK
mapping (unless MAP_FIXED is used of course).

The proper method of making a MAP_STACK mapping inside another MAP_STACK
mapping is to use MAP_STACK | MAP_TRYFIXED.  For now, though, we silently
imply MAP_TRYFIXED when MAP_STACK is specified and it will work without it.

Document MAP_TRYFIXED and make it also relax additional requirements imposed
by MAP_STACK mappings inside of MAP_STACK mappings.

Adjust libthread_xu to use MAP_STACK | MAP_TRYFIXED.
lib/libc/sys/mmap.2
lib/libthread_xu/thread/thr_stack.c
sys/kern/kern_exec.c
sys/kern/kern_slaballoc.c
sys/kern/vfs_bio.c
sys/vm/vm_contig.c
sys/vm/vm_kern.c
sys/vm/vm_map.c
sys/vm/vm_map.h
sys/vm/vm_mmap.c