• Roland McGrath's avatar
    [PATCH] PROT_GROWSDOWN/PROT_GROWSUP flags for mprotect · c1dd5958
    Roland McGrath authored
    There is currently no clean and efficient way to apply mprotect to all of a
    program's stack, i.e. to the moving edge of a GROWSDOWN or GROWSUP mapping.
    Some processes want to change these protections, particularly to set or
    clear the PROT_EXEC bits on stack space.  As it is, an mprotect done to
    cover the precise edge page of the mapping will have the desired effect of
    changing the protection for existing pages and having that new protection
    carried over to new pages grown later.  But there is no very reasonable way
    of ascertaining where the edge of the mapping is if it might have grown in
    the past beyond the usage at the moment.  An mprotect call that doesn't
    cover the edge page splits the mapping and doesn't do what we need.
    
    This patch adds flags that can be OR'd into the protection bits in an
    mprotect system call.  PROT_GROWSDOWN means the memory lies in a GROWSDOWN
    mapping and the start address of the region to be changed should be
    extended down t...
    c1dd5958
mprotect.c 7.23 KB