[PATCH v4 1/5] support: Add support_stack_alloc

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Mar 12 14:01:49 GMT 2021



On 12/03/2021 10:35, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> On 10/03/2021 13:10, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>>
>>>> +  /* Use MAP_NORESERVE so that RAM will not be wasted on the guard
>>>> +     bands; touch all the pages of the actual stack before returning,
>>>> +     so we know they are allocated.  */
>>>> +  void *alloc_base = xmmap (0,
>>>> +                            alloc_size,
>>>> +                            PROT_READ|PROT_WRITE,
>>>> +                            MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE|MAP_STACK,
>>>> +                            -1);
>>>> +  xmprotect (alloc_base, guardsize, PROT_NONE);
>>>> +  xmprotect (alloc_base + guardsize + stacksize, guardsize, PROT_NONE);
>>>
>>> The usual pattern is to map with PROT_NONE and then use
>>> PROT_READ|PROT_WRITE with mprotect.
>>>
>>> Rest looks okay, thanks.
>>>
>>> Florian
>>>
>>
>> Ok, I will fix it and push upstream.
> 
> Just to be clear, it avoids the need for MAP_NORESERVE.

Right, I will fix it.


More information about the Libc-alpha mailing list