diff --git a/glibc-testsuite.changes b/glibc-testsuite.changes index 814362d..fbb9718 100644 --- a/glibc-testsuite.changes +++ b/glibc-testsuite.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Oct 26 08:40:52 UTC 2017 - schwab@suse.de + +- spawni-assert.patch: Fix improper assert in Linux posix_spawn (BZ + #22273) + ------------------------------------------------------------------- Mon Oct 23 09:35:18 UTC 2017 - schwab@suse.de diff --git a/glibc-testsuite.spec b/glibc-testsuite.spec index ef9e588..117ed8a 100644 --- a/glibc-testsuite.spec +++ b/glibc-testsuite.spec @@ -309,6 +309,8 @@ Patch1018: sysconf-uio-maxiov.patch Patch1019: glob-tilde-overflow.patch # PATCH-FIX-UPSTREAM x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve (BZ #21265) Patch1020: dl-runtime-resolve-xsave.patch +# PATCH-FIX-UPSTREAM posix: Fix improper assert in Linux posix_spawn (BZ #22273) +Patch1021: spawni-assert.patch ### # Patches awaiting upstream approval @@ -540,6 +542,7 @@ rm nscd/s-stamp %patch1018 -p1 %patch1019 -p1 %patch1020 -p1 +%patch1021 -p1 %patch2000 -p1 %patch2001 -p1 diff --git a/glibc-utils.changes b/glibc-utils.changes index 814362d..fbb9718 100644 --- a/glibc-utils.changes +++ b/glibc-utils.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Oct 26 08:40:52 UTC 2017 - schwab@suse.de + +- spawni-assert.patch: Fix improper assert in Linux posix_spawn (BZ + #22273) + ------------------------------------------------------------------- Mon Oct 23 09:35:18 UTC 2017 - schwab@suse.de diff --git a/glibc-utils.spec b/glibc-utils.spec index c112e97..3cee131 100644 --- a/glibc-utils.spec +++ b/glibc-utils.spec @@ -309,6 +309,8 @@ Patch1018: sysconf-uio-maxiov.patch Patch1019: glob-tilde-overflow.patch # PATCH-FIX-UPSTREAM x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve (BZ #21265) Patch1020: dl-runtime-resolve-xsave.patch +# PATCH-FIX-UPSTREAM posix: Fix improper assert in Linux posix_spawn (BZ #22273) +Patch1021: spawni-assert.patch ### # Patches awaiting upstream approval @@ -540,6 +542,7 @@ rm nscd/s-stamp %patch1018 -p1 %patch1019 -p1 %patch1020 -p1 +%patch1021 -p1 %patch2000 -p1 %patch2001 -p1 diff --git a/glibc.changes b/glibc.changes index 814362d..fbb9718 100644 --- a/glibc.changes +++ b/glibc.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Oct 26 08:40:52 UTC 2017 - schwab@suse.de + +- spawni-assert.patch: Fix improper assert in Linux posix_spawn (BZ + #22273) + ------------------------------------------------------------------- Mon Oct 23 09:35:18 UTC 2017 - schwab@suse.de diff --git a/glibc.spec b/glibc.spec index 4334780..af39f1a 100644 --- a/glibc.spec +++ b/glibc.spec @@ -315,6 +315,8 @@ Patch1018: sysconf-uio-maxiov.patch Patch1019: glob-tilde-overflow.patch # PATCH-FIX-UPSTREAM x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve (BZ #21265) Patch1020: dl-runtime-resolve-xsave.patch +# PATCH-FIX-UPSTREAM posix: Fix improper assert in Linux posix_spawn (BZ #22273) +Patch1021: spawni-assert.patch ### # Patches awaiting upstream approval @@ -546,6 +548,7 @@ rm nscd/s-stamp %patch1018 -p1 %patch1019 -p1 %patch1020 -p1 +%patch1021 -p1 %patch2000 -p1 %patch2001 -p1 diff --git a/spawni-assert.patch b/spawni-assert.patch new file mode 100644 index 0000000..429c5cf --- /dev/null +++ b/spawni-assert.patch @@ -0,0 +1,71 @@ +2017-10-23 Adhemerval Zanella + + * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Use 0 instead of + WNOHANG in waitpid call. + +2017-10-20 Adhemerval Zanella + + [BZ #22273] + * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Handle the case where + the auxiliary process is terminated by a signal before calling _exit + or execve. + +Index: glibc-2.26/sysdeps/unix/sysv/linux/spawni.c +=================================================================== +--- glibc-2.26.orig/sysdeps/unix/sysv/linux/spawni.c ++++ glibc-2.26/sysdeps/unix/sysv/linux/spawni.c +@@ -17,7 +17,6 @@ + . */ + + #include +-#include + #include + #include + #include +@@ -268,7 +267,6 @@ __spawni_child (void *arguments) + __sigprocmask (SIG_SETMASK, (attr->__flags & POSIX_SPAWN_SETSIGMASK) + ? &attr->__ss : &args->oldmask, 0); + +- args->err = 0; + args->exec (args->file, args->argv, args->envp); + + /* This is compatibility function required to enable posix_spawn run +@@ -339,7 +337,7 @@ __spawnix (pid_t * pid, const char *file + + /* Child must set args.err to something non-negative - we rely on + the parent and child sharing VM. */ +- args.err = -1; ++ args.err = 0; + args.file = file; + args.exec = exec; + args.fa = file_actions; +@@ -362,12 +360,26 @@ __spawnix (pid_t * pid, const char *file + new_pid = CLONE (__spawni_child, STACK (stack, stack_size), stack_size, + CLONE_VM | CLONE_VFORK | SIGCHLD, &args); + ++ /* It needs to collect the case where the auxiliary process was created ++ but failed to execute the file (due either any preparation step or ++ for execve itself). */ + if (new_pid > 0) + { ++ /* Also, it handles the unlikely case where the auxiliary process was ++ terminated before calling execve as if it was successfully. The ++ args.err is set to 0 as default and changed to a positive value ++ only in case of failure, so in case of premature termination ++ due a signal args.err will remain zeroed and it will be up to ++ caller to actually collect it. */ + ec = args.err; +- assert (ec >= 0); +- if (ec != 0) +- __waitpid (new_pid, NULL, 0); ++ if (ec > 0) ++ /* There still an unlikely case where the child is cancelled after ++ setting args.err, due to a positive error value. Also there is ++ possible pid reuse race (where the kernel allocated the same pid ++ to an unrelated process). Unfortunately due synchronization ++ issues where the kernel might not have the process collected ++ the waitpid below can not use WNOHANG. */ ++ __waitpid (new_pid, NULL, 0); + } + else + ec = -new_pid;