glibc/sysdeps/unix/sysv/linux/s390/s390-32
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
..
____longjmp_chk.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
__makecontext_ret.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
alphasort64.c
c++-types.data S390: Consolidate nptl/ subdirectories under linux/... 2014-06-26 09:34:34 -07:00
clone.S posix: New Linux posix_spawn{p} implementation 2016-03-07 11:53:47 +07:00
fcntl.c
fxstat.c
fxstatat.c
getcontext.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getdents64.c
getrlimit64.c
getutent_r.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutent.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutid_r.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutid.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutline_r.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutline.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutmp.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutxent.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutxid.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getutxline.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00: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
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
lockf64.c
login32.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
login.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
lxstat.c
makecontext.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Makefile S/390: Fix uc_link == NULL handling for makecontext 2012-07-19 15:58:17 +02:00
mmap64.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
mmap.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
oldgetrlimit64.c
posix_fadvise64.c 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
pututxline.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
readdir64_r.c
readdir64.c
register-dump.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
scandir64.c
setcontext.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
setegid.c
seteuid.c
setgid.c
setgroups.c
setregid.c
setresgid.c
setresuid.c
setreuid.c
setuid.c
swapcontext.S 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 Fix linux personality syscall wrapper 2015-12-31 00:17:48 +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
sysdep.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
updwtmp.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
updwtmpx.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
utmp32.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
utmp32.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
utmp-compat.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
utmp-convert.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
utmpx32.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
utmpx32.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
utmpx-convert.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Versions Move some chown / lchown / fchown definitions to syscalls.list (bug 14138). 2014-10-24 12:59:23 +00:00
versionsort64.c
vfork.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
xstat.c