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

Joseph Myers joseph@codesourcery.com
Mon Feb 1 16:52:00 GMT 2016


On Mon, 1 Feb 2016, Adhemerval Zanella wrote:

> +  char *argv[argc+1];
> +  va_start (ap, arg);
> +  argv[0] = (char*) arg;
> +  for (i = 1; i < argc; i++)
> +     argv[i] = va_arg (ap, char *);
> +  argv[i] = NULL;

I don't see how you're ensuring this stack allocation is safe (i.e. if 
it's too big, it doesn't corrupt memory that's in use by other threads).  
Can't it jump beyond any guard page and start overwriting other memory, 
possibly in use by another thread, before reaching unmapped memory?  I'd 
expect safe large stack allocations (as with -fstack-check) to need to 
touch the pages in the right order (and doing that safely probably means 
using -fstack-check).

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Libc-alpha mailing list