[PATCH v4 1/5] support: Add support_stack_alloc
Florian Weimer
fweimer@redhat.com
Fri Mar 12 13:35:43 GMT 2021
* 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.
Thanks,
Florian
More information about the Libc-alpha
mailing list