[PATCH] posix: Remove dynamic memory allocation from execl{e,p}

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Jan 29 18:05:00 GMT 2016



On 29-01-2016 15:45, Joseph Myers wrote:
> On Fri, 29 Jan 2016, Adhemerval Zanella wrote:
> 
>> My view is for such function is just try to allocate the buffer on
>> stack and allow it fails through invalid access in case of buffer
>> overflow.
> 
> I'd say just trying the allocation is OK in this case (if stack allocation 
> is all that's permitted by the function semantics, and bearing in mind 
> that current Linux versions determine ARG_MAX dynamically based on the 
> stack limit) *if* it's allocated in a way that guarantees failure if it's 
> too large (i.e. touching each page in turn) rather than potentially 
> overflowing into unrelated memory.
>

That is the idea, the buffer is allocated to exactly fit the required
arguments (different that current algorithm that double each iteration).

For posix_spawn{p} I used a different strategy for the clone(VFORK),
which I think it is slight better but does impose some constraints:
allocate a mmap(STACK) with default architecture stack size and set
is as the stack for children. I think it is better than possible clobber
a stack allocated buffer from parent.



More information about the Libc-alpha mailing list