[PATCH v2] posix_spawn: use a larger min stack for -fstack-check [BZ #21253]

Mike Frysinger vapier@gentoo.org
Wed Mar 22 06:11:00 GMT 2017


On 17 Mar 2017 12:09, Mike Frysinger wrote:
> When glibc is built with -fstack-check, trying to use posix_spawn can
> lead to segfaults due to gcc internally probing stack memory too far.
> The new spawn API will allocate a minimum of 1 page, but the stack
> checking logic might probe a couple of pages.  When it tries to walk
> them, everything falls apart.
> 
> The gcc internal docs [1] state the default interval checking is one
> page.  Which means we need two pages (the current one, and the next
> probed).  No target currently defines it larger.
> 
> Further, it mentions that the default minimum stack size needed to
> recover from an overflow is 4/8KiB for sjlj or 8/12KiB for others.
> But some Linux targets (like mips and ppc) go up to 16KiB (and some
> non-Linux targets go up to 24KiB).
> 
> Let's create each child with a minimum of 32KiB slack space to support
> them all, and give us future breathing room.
> 
> No test is added as existing ones crash.  Even a simple call is
> enough to trigger the problem:
> 	char *argv[] = { "/bin/ls", NULL };
> 	posix_spawn(NULL, "/bin/ls", NULL, NULL, argv, NULL);

ignoring the style change, what do people think of the technical change
here ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170322/37985c3f/attachment.sig>


More information about the Libc-alpha mailing list