glibc/sysdeps/unix/sysv/linux/sparc/sparc64
Adhemerval Zanella 9ff72da471 posix: New Linux posix_spawn{p} implementation
This patch implements a new posix_spawn{p} implementation for Linux.  The main
difference is it uses the clone syscall directly with CLONE_VM and CLONE_VFORK
flags and a direct allocated stack.  The new stack and start function solves
most the vfork limitation (possible parent clobber due stack spilling).  The
remaning issue are related to signal handling:

  1. That no signal handlers must run in child context, to avoid corrupt
     parent's state.
  2. Child must synchronize with parent to enforce stack deallocation and
     to possible return execv issues.

The first one is solved by blocking all signals in child, even NPTL-internal
ones (SIGCANCEL and SIGSETXID).  The second issue is done by a stack allocation
in parent and a synchronization with using a pipe or waitpid (in case or error).
The pipe has the advantage of allowing the child signal an exec error (checked
with new tst-spawn2 test).

There is an inherent race condition in pipe2 usage for architectures that do not
support the syscall directly.  In such cases the a pipe plus fctnl is used
instead and it may lead to file descriptor leak in parent (as decribed by fcntl
documentation).

The child process stack is allocate with a mmap with MAP_STACK flag using
default architecture stack size.  Although it is slower than use a stack buffer
from parent, it allows some slack for the compatibility code to run scripts
with no shebang (which may use a buffer with size depending of argument list
count).

Performance should be similar to the vfork default posix implementation and
way faster than fork path (vfork on mostly linux ports are basically
clone with CLONE_VM plus CLONE_VFORK).  The only difference is the syscalls
required for the stack allocation/deallocation.

It fixes BZ#10354, BZ#14750, and BZ#18433.

Tested on i386, x86_64, powerpc64le, and aarch64.

	[BZ #14750]
	[BZ #10354]
	[BZ #18433]
	* include/sched.h (__clone): Add hidden prototype.
	(__clone2): Likewise.
	* include/unistd.h (__dup): Likewise.
	* posix/Makefile (tests): Add tst-spawn2.
	* posix/tst-spawn2.c: New file.
	* sysdeps/posix/dup.c (__dup): Add hidden definition.
	* sysdeps/unix/sysv/linux/aarch64/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/alpha/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/arm/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/hppa/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/i386/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/ia64/clone2.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/m68k/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/mips/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/nios2/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S (__clone):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S (__clone):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/sh/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/tile/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/nptl-signals.h
	(____nptl_is_internal_signal): New function.
	* sysdeps/unix/sysv/linux/spawni.c: New file.
2016-03-07 11:53:47 +07:00
..
Implies Update. 2004-03-24 00:06:13 +00:00
Makefile Move remaining SPARC code out of nptl/. 2014-06-20 17:13:47 -07:00
Versions Move remaining SPARC code out of nptl/. 2014-06-20 17:13:47 -07:00
____longjmp_chk.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
__longjmp.S
__start_context.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
brk.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
bsd-_setjmp.S
bsd-setjmp.S
c++-types.data SPARC: Consolidate nptl/ subdirectories under linux/... 2014-06-25 10:03:52 -07:00
clone.S posix: New Linux posix_spawn{p} implementation 2016-03-07 11:53:47 +07:00
configure Rename localedir to complocaledir (bug 14259). 2015-11-27 10:22:38 -05:00
configure.ac Refactor handling of /lib64 etc. cases, move out of sysdeps/gnu/configure.ac. 2014-07-17 14:35:48 +00:00
dl-brk.S Update. 2002-04-06 01:45:15 +00:00
dl-cache.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
dl-fxstatat64.c Remove __ASSUME_ATFCTS conditionals in sysdeps/unix/sysv/linux/. 2014-06-20 15:41:35 +00:00
fxstat.c sparc64: Use i386 implementation for fxstat. 2011-01-04 12:22:41 -08:00
fxstatat.c Adjust for recent input file changes. 2006-01-09 19:50:01 +00:00
get_clockfreq.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getcontext.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
kernel_stat.h Use __glibc_reserved instead __unused. 2013-11-26 12:32:28 +01:00
ld.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libBrokenLocale.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libanl.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libc.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libcrypt.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libdl.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libm.abilist Fix lgamma setting signgam for ISO C (bug 15421). 2015-11-20 22:49:59 +00:00
libnsl.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libpthread.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libresolv.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
librt.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libthread_db.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libutil.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
localplt.data Update sparc localplt.data 2015-04-27 14:53:13 -07:00
longjmp.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
lxstat.c * sysdeps/unix/sysv/linux/sparc/bits/setjmp.h (_JMPBUF_UNWINDS): Add 2006-01-09 21:17:57 +00:00
makecontext.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
msgrcv.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
pause.c [BZ #3291] 2006-10-02 18:41:30 +00:00
personality.c Fix linux personality syscall wrapper 2015-12-31 00:17:48 +00:00
pipe.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
profil-counter.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
register-dump.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
semctl.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
setcontext.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
setjmp.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
shlib-versions Remove configuration name patterns from shlib-versions. 2014-09-12 12:28:47 +00:00
sigaction.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
sigcontextinfo.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
sigjmp.S
sigpending.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
sigprocmask.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
sizes.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
swapcontext.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
syscall.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
syscalls.list Remove stray *_internal aliases (bug 14132). 2014-10-09 01:11:14 +00:00
sysdep-cancel.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
sysdep.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
time.c Adjust old #include's of sysdeps/unix/time.c to point to sysdeps/posix/time.c instead. 2012-08-17 14:16:12 -07:00
timer_create.c Move remaining SPARC code out of nptl/. 2014-06-20 17:13:47 -07:00
timer_delete.c Move remaining SPARC code out of nptl/. 2014-06-20 17:13:47 -07:00
timer_getoverr.c Move remaining SPARC code out of nptl/. 2014-06-20 17:13:47 -07:00
timer_gettime.c Move remaining SPARC code out of nptl/. 2014-06-20 17:13:47 -07:00
timer_settime.c Move remaining SPARC code out of nptl/. 2014-06-20 17:13:47 -07:00
ucontext_i.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
vfork.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
wordexp.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
xstat.c Remove __ASSUME_STAT64_SYSCALL. 2012-08-27 19:36:04 +00:00
xstatconv.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00