Fix libthread_xu's use of MAP_STACK. Guards were not being setup properly.
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 23 Apr 2009 20:05:24 +0000 (13:05 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 23 Apr 2009 20:05:24 +0000 (13:05 -0700)
commit2035b67992ac162a5968a22584ef29d2f53f93e2
tree70416531a9c1a07ba33bf265982970f1951b1cfa
parent7828f05d0a845055d543f5fb96de64162f3b0990
Fix libthread_xu's use of MAP_STACK.  Guards were not being setup properly.

MAP_STACK mappings do not immediately extend down to their base, so calling
mprotect() on the base is basically a NOP.  Instead of calling mprotect() we
call mmap() with MAP_FIXED to force the guard.

Properly use MAP_FIXED when setting up the primary guard on the original
user stack.  The address specified in the mmap() is only a hint when MAP_FIXED
is not used, and will not properly map the anonymous area.  Also, new kernels
do not allow non-MAP_STACK mappings to override MAP_STACK mappings and the
user stack area is a MAP_STACK mapping, so use of MAP_FIXED is mandatory here.
lib/libthread_xu/thread/thr_init.c
lib/libthread_xu/thread/thr_stack.c