Hello community, here is the log from the commit of package glibc for openSUSE:Factory checked in at 2017-11-15 16:48:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/glibc (Old) and /work/SRC/openSUSE:Factory/.glibc.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "glibc" Wed Nov 15 16:48:09 2017 rev:216 rq:536907 version:2.26 Changes: -------- --- /work/SRC/openSUSE:Factory/glibc/glibc-testsuite.changes 2017-10-20 14:38:24.305197570 +0200 +++ /work/SRC/openSUSE:Factory/.glibc.new/glibc-testsuite.changes 2017-11-15 16:48:20.540825237 +0100 @@ -1,0 +2,25 @@ +Thu Oct 26 08:40:52 UTC 2017 - [email protected] + +- spawni-assert.patch: Fix improper assert in Linux posix_spawn (BZ + #22273) + +------------------------------------------------------------------- +Mon Oct 23 09:35:18 UTC 2017 - [email protected] + +- math-c++-compat.patch: Add more C++ compatibility (BZ #22296) +- malloc-tcache-leak.patch: Fix tcache leak after thread destruction (BZ + #22111) +- falkor-memcpy-memmove.patch: Optimized implementation of memcpy/memmove + for Qualcomm Falkor +- aarch64-cpu-features.patch: Fix glibc.tune.cpu tunable handling +- nss-files-large-buffers.patch: Avoid large buffers with many host + addresses (BZ #22078) +- sysconf-uio-maxiov.patch: Fix missing definition of UIO_MAXIOV (BZ + #22321) +- glob-tilde-overflow.patch: Fix buffer overflows with GLOB_TILDE + (CVE-2017-15670, CVE-2017-15671, CVE-2017-15804, + bsc#1064569. bsc#1064580, bsc#1064583, BZ #22320, BZ #22325, BZ #22332) +- dl-runtime-resolve-xsave.patch: Use fxsave/xsave/xsavec in + _dl_runtime_resolve (BZ #21265) + +------------------------------------------------------------------- @@ -25 +50 @@ -- math-c++-compat.patch: Add more C++ compatibility +- math-c++-compat.patch: Add more C++ compatibility (BZ #22235) glibc-utils.changes: same change glibc.changes: same change New: ---- aarch64-cpu-features.patch dl-runtime-resolve-xsave.patch falkor-memcpy-memmove.patch glob-tilde-overflow.patch malloc-tcache-leak.patch nss-files-large-buffers.patch spawni-assert.patch sysconf-uio-maxiov.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ glibc-testsuite.spec ++++++ --- /var/tmp/diff_new_pack.vWDO4C/_old 2017-11-15 16:48:22.192764708 +0100 +++ /var/tmp/diff_new_pack.vWDO4C/_new 2017-11-15 16:48:22.192764708 +0100 @@ -273,7 +273,7 @@ Patch1001: dl-runtime-resolve-opt-avx512f.patch # PATCH-FIX-UPSTREAM Don't use IFUNC resolver for longjmp or system in libpthread (BZ #21041) Patch1002: libpthread-compat-wrappers.patch -# PATCH-FIX-UPSTREAM Do not use __builtin_types_compatible_p in C++ mode (BZ #21930) +# PATCH-FIX-UPSTREAM Do not use __builtin_types_compatible_p in C++ mode (BZ #21930, BZ #22146, BZ #22235, BZ #22296) Patch1003: math-c++-compat.patch # PATCH-FIX-UPSTREAM Remove nis and compat from default NSS configs Patch1004: remove-nss-nis-compat.patch @@ -295,6 +295,22 @@ Patch1012: nss-compat.patch # PATCH-FIX-UPSTREAM Remove reference to libnsl from nscd Patch1013: nscd-libnsl.patch +# PATCH-FIX-UPSTREAM malloc: Fix tcache leak after thread destruction (BZ #22111) +Patch1014: malloc-tcache-leak.patch +# PATCH-FIX-UPSTREAM aarch64: Optimized implementation of memcpy/memmove for Qualcomm Falkor +Patch1015: falkor-memcpy-memmove.patch +# PATCH-FIX-UPSTREAM aarch64: Fix glibc.tune.cpu tunable handling +Patch1016: aarch64-cpu-features.patch +# PATCH-FIX-UPSTREAM nss_files: Avoid large buffers with many host addresses (BZ #22078) +Patch1017: nss-files-large-buffers.patch +# PATCH-FIX-UPSTREAM sysconf: Fix missing definition of UIO_MAXIOV on Linux (BZ #22321) +Patch1018: sysconf-uio-maxiov.patch +# PATCH-FIX-UPSTREAM glob: Fix buffer overflows (CVE-2017-15670, CVE-2017-15671, CVE-2017-15804, BZ #22320, BZ #22325, BZ #22332) +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 @@ -519,6 +535,14 @@ %patch1011 -p1 %patch1012 -p1 %patch1013 -p1 +%patch1014 -p1 +%patch1015 -p1 +%patch1016 -p1 +%patch1017 -p1 +%patch1018 -p1 +%patch1019 -p1 +%patch1020 -p1 +%patch1021 -p1 %patch2000 -p1 %patch2001 -p1 glibc-utils.spec: same change ++++++ glibc.spec ++++++ --- /var/tmp/diff_new_pack.vWDO4C/_old 2017-11-15 16:48:22.240762950 +0100 +++ /var/tmp/diff_new_pack.vWDO4C/_new 2017-11-15 16:48:22.244762803 +0100 @@ -279,7 +279,7 @@ Patch1001: dl-runtime-resolve-opt-avx512f.patch # PATCH-FIX-UPSTREAM Don't use IFUNC resolver for longjmp or system in libpthread (BZ #21041) Patch1002: libpthread-compat-wrappers.patch -# PATCH-FIX-UPSTREAM Do not use __builtin_types_compatible_p in C++ mode (BZ #21930) +# PATCH-FIX-UPSTREAM Do not use __builtin_types_compatible_p in C++ mode (BZ #21930, BZ #22146, BZ #22235, BZ #22296) Patch1003: math-c++-compat.patch # PATCH-FIX-UPSTREAM Remove nis and compat from default NSS configs Patch1004: remove-nss-nis-compat.patch @@ -301,6 +301,22 @@ Patch1012: nss-compat.patch # PATCH-FIX-UPSTREAM Remove reference to libnsl from nscd Patch1013: nscd-libnsl.patch +# PATCH-FIX-UPSTREAM malloc: Fix tcache leak after thread destruction (BZ #22111) +Patch1014: malloc-tcache-leak.patch +# PATCH-FIX-UPSTREAM aarch64: Optimized implementation of memcpy/memmove for Qualcomm Falkor +Patch1015: falkor-memcpy-memmove.patch +# PATCH-FIX-UPSTREAM aarch64: Fix glibc.tune.cpu tunable handling +Patch1016: aarch64-cpu-features.patch +# PATCH-FIX-UPSTREAM nss_files: Avoid large buffers with many host addresses (BZ #22078) +Patch1017: nss-files-large-buffers.patch +# PATCH-FIX-UPSTREAM sysconf: Fix missing definition of UIO_MAXIOV on Linux (BZ #22321) +Patch1018: sysconf-uio-maxiov.patch +# PATCH-FIX-UPSTREAM glob: Fix buffer overflows (CVE-2017-15670, CVE-2017-15671, CVE-2017-15804, BZ #22320, BZ #22325, BZ #22332) +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 @@ -525,6 +541,14 @@ %patch1011 -p1 %patch1012 -p1 %patch1013 -p1 +%patch1014 -p1 +%patch1015 -p1 +%patch1016 -p1 +%patch1017 -p1 +%patch1018 -p1 +%patch1019 -p1 +%patch1020 -p1 +%patch1021 -p1 %patch2000 -p1 %patch2001 -p1 ++++++ aarch64-cpu-features.patch ++++++ 2017-10-10 Steve Ellcey <[email protected]> * sysdeps/unix/sysv/linux/aarch64/cpu-features.c (get_midr_from_mcpu): Use strcmp instead of tunable_is_name. Index: glibc-2.26/sysdeps/unix/sysv/linux/aarch64/cpu-features.c =================================================================== --- glibc-2.26.orig/sysdeps/unix/sysv/linux/aarch64/cpu-features.c +++ glibc-2.26/sysdeps/unix/sysv/linux/aarch64/cpu-features.c @@ -37,7 +37,7 @@ static uint64_t get_midr_from_mcpu (const char *mcpu) { for (int i = 0; i < sizeof (cpu_list) / sizeof (struct cpu_list); i++) - if (tunable_is_name (mcpu, cpu_list[i].name) == 0) + if (strcmp (mcpu, cpu_list[i].name) == 0) return cpu_list[i].midr; return UINT64_MAX; ++++++ dl-runtime-resolve-xsave.patch ++++++ ++++ 851 lines (skipped) ++++++ falkor-memcpy-memmove.patch ++++++ 2017-10-10 Siddhesh Poyarekar <[email protected]> * sysdeps/aarch64/multiarch/Makefile (sysdep_routines): Add memmove_falkor. * sysdeps/aarch64/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Likewise. * sysdeps/aarch64/multiarch/memmove.c: Likewise. * sysdeps/aarch64/multiarch/memmove_falkor.S: New file. * benchtests/bench-memmove-walk.c: New file. * benchtests/Makefile (string-benchset): Add it. * benchtests/bench-memset-walk.c: New file. * benchtests/Makefile (string-benchset): Add it. * benchtests/bench-memcpy-walk.c: New file. * benchtests/Makefile (string-benchset): Add it. 2017-10-10 Siddhesh Poyarekar <[email protected]> * manual/tunables.texi (Tunable glibc.tune.cpu): Add falkor. * sysdeps/aarch64/multiarch/Makefile (sysdep_routines): Add memcpy_falkor. * sysdeps/aarch64/multiarch/ifunc-impl-list.c (MAX_IFUNC): Bump. (__libc_ifunc_impl_list): Add __memcpy_falkor. * sysdeps/aarch64/multiarch/memcpy.c: Likewise. * sysdeps/aarch64/multiarch/memcpy_falkor.S: New file. * sysdeps/unix/sysv/linux/aarch64/cpu-features.c (cpu_list): Add falkor. * sysdeps/unix/sysv/linux/aarch64/cpu-features.h (IS_FALKOR): New macro. Index: glibc-2.26/manual/tunables.texi =================================================================== --- glibc-2.26.orig/manual/tunables.texi +++ glibc-2.26/manual/tunables.texi @@ -267,7 +267,7 @@ This tunable is specific to i386 and x86 @deftp Tunable glibc.tune.cpu The @code{glibc.tune.cpu=xxx} tunable allows the user to tell @theglibc{} to assume that the CPU is @code{xxx} where xxx may have one of these values: -@code{generic}, @code{thunderxt88}. +@code{generic}, @code{falkor}, @code{thunderxt88}. This tunable is specific to aarch64. @end deftp Index: glibc-2.26/sysdeps/aarch64/multiarch/Makefile =================================================================== --- glibc-2.26.orig/sysdeps/aarch64/multiarch/Makefile +++ glibc-2.26/sysdeps/aarch64/multiarch/Makefile @@ -1,3 +1,4 @@ ifeq ($(subdir),string) -sysdep_routines += memcpy_generic memcpy_thunderx +sysdep_routines += memcpy_generic memcpy_thunderx memcpy_falkor \ + memmove_falkor endif Index: glibc-2.26/sysdeps/aarch64/multiarch/ifunc-impl-list.c =================================================================== --- glibc-2.26.orig/sysdeps/aarch64/multiarch/ifunc-impl-list.c +++ glibc-2.26/sysdeps/aarch64/multiarch/ifunc-impl-list.c @@ -25,7 +25,7 @@ #include <stdio.h> /* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 2 +#define MAX_IFUNC 3 size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, @@ -40,9 +40,11 @@ __libc_ifunc_impl_list (const char *name /* Support sysdeps/aarch64/multiarch/memcpy.c and memmove.c. */ IFUNC_IMPL (i, name, memcpy, IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_thunderx) + IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_falkor) IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_generic)) IFUNC_IMPL (i, name, memmove, IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_thunderx) + IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_falkor) IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_generic)) return i; Index: glibc-2.26/sysdeps/aarch64/multiarch/memcpy.c =================================================================== --- glibc-2.26.orig/sysdeps/aarch64/multiarch/memcpy.c +++ glibc-2.26/sysdeps/aarch64/multiarch/memcpy.c @@ -30,9 +30,14 @@ extern __typeof (__redirect_memcpy) __li extern __typeof (__redirect_memcpy) __memcpy_generic attribute_hidden; extern __typeof (__redirect_memcpy) __memcpy_thunderx attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_falkor attribute_hidden; libc_ifunc (__libc_memcpy, - IS_THUNDERX (midr) ? __memcpy_thunderx : __memcpy_generic); + (IS_THUNDERX (midr) + ? __memcpy_thunderx + : (IS_FALKOR (midr) + ? __memcpy_falkor + : __memcpy_generic))); # undef memcpy strong_alias (__libc_memcpy, memcpy); Index: glibc-2.26/sysdeps/aarch64/multiarch/memcpy_falkor.S =================================================================== --- /dev/null +++ glibc-2.26/sysdeps/aarch64/multiarch/memcpy_falkor.S @@ -0,0 +1,184 @@ +/* Optimized memcpy for Qualcomm Falkor processor. + Copyright (C) 2017 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + +/* Assumptions: + + ARMv8-a, AArch64, falkor, unaligned accesses. */ + +#define dstin x0 +#define src x1 +#define count x2 +#define dst x3 +#define srcend x4 +#define dstend x5 +#define A_l x6 +#define A_lw w6 +#define A_h x7 +#define A_hw w7 +#define tmp1 x14 + +/* Copies are split into 3 main cases: + + 1. Small copies of up to 32 bytes + 2. Medium copies of 33..128 bytes which are fully unrolled + 3. Large copies of more than 128 bytes. + + Large copies align the sourceto a quad word and use an unrolled loop + processing 64 bytes per iteration. + + FALKOR-SPECIFIC DESIGN: + + The smallest copies (32 bytes or less) focus on optimal pipeline usage, + which is why the redundant copies of 0-3 bytes have been replaced with + conditionals, since the former would unnecessarily break across multiple + issue groups. The medium copy group has been enlarged to 128 bytes since + bumping up the small copies up to 32 bytes allows us to do that without + cost and also allows us to reduce the size of the prep code before loop64. + + All copies are done only via two registers r6 and r7. This is to ensure + that all loads hit a single hardware prefetcher which can get correctly + trained to prefetch a single stream. + + The non-temporal stores help optimize cache utilization. */ + +#if IS_IN (libc) +ENTRY_ALIGN (__memcpy_falkor, 6) + + cmp count, 32 + add srcend, src, count + add dstend, dstin, count + b.ls L(copy32) + ldp A_l, A_h, [src] + cmp count, 128 + stp A_l, A_h, [dstin] + b.hi L(copy_long) + + /* Medium copies: 33..128 bytes. */ + sub tmp1, count, 1 + ldp A_l, A_h, [src, 16] + stp A_l, A_h, [dstin, 16] + tbz tmp1, 6, 1f + ldp A_l, A_h, [src, 32] + stp A_l, A_h, [dstin, 32] + ldp A_l, A_h, [src, 48] + stp A_l, A_h, [dstin, 48] + ldp A_l, A_h, [srcend, -64] + stp A_l, A_h, [dstend, -64] + ldp A_l, A_h, [srcend, -48] + stp A_l, A_h, [dstend, -48] +1: + ldp A_l, A_h, [srcend, -32] + stp A_l, A_h, [dstend, -32] + ldp A_l, A_h, [srcend, -16] + stp A_l, A_h, [dstend, -16] + ret + + .p2align 4 + /* Small copies: 0..32 bytes. */ +L(copy32): + /* 16-32 */ + cmp count, 16 + b.lo 1f + ldp A_l, A_h, [src] + stp A_l, A_h, [dstin] + ldp A_l, A_h, [srcend, -16] + stp A_l, A_h, [dstend, -16] + ret + .p2align 4 +1: + /* 8-15 */ + tbz count, 3, 1f + ldr A_l, [src] + str A_l, [dstin] + ldr A_l, [srcend, -8] + str A_l, [dstend, -8] + ret + .p2align 4 +1: + /* 4-7 */ + tbz count, 2, 1f + ldr A_lw, [src] + str A_lw, [dstin] + ldr A_lw, [srcend, -4] + str A_lw, [dstend, -4] + ret + .p2align 4 +1: + /* 2-3 */ + tbz count, 1, 1f + ldrh A_lw, [src] + strh A_lw, [dstin] + ldrh A_lw, [srcend, -2] + strh A_lw, [dstend, -2] + ret + .p2align 4 +1: + /* 0-1 */ + tbz count, 0, 1f + ldrb A_lw, [src] + strb A_lw, [dstin] +1: + ret + + /* Align SRC to 16 bytes and copy; that way at least one of the + accesses is aligned throughout the copy sequence. + + The count is off by 0 to 15 bytes, but this is OK because we trim + off the last 64 bytes to copy off from the end. Due to this the + loop never runs out of bounds. */ + .p2align 6 +L(copy_long): + sub count, count, 64 + 16 + and tmp1, src, 15 + bic src, src, 15 + sub dst, dstin, tmp1 + add count, count, tmp1 + +L(loop64): + ldp A_l, A_h, [src, 16]! + stnp A_l, A_h, [dst, 16] + ldp A_l, A_h, [src, 16]! + subs count, count, 64 + stnp A_l, A_h, [dst, 32] + ldp A_l, A_h, [src, 16]! + stnp A_l, A_h, [dst, 48] + ldp A_l, A_h, [src, 16]! + stnp A_l, A_h, [dst, 64] + add dst, dst, 64 + b.hi L(loop64) + + /* Write the last full set of 64 bytes. The remainder is at most 64 + bytes, so it is safe to always copy 64 bytes from the end even if + there is just 1 byte left. */ +L(last64): + ldp A_l, A_h, [srcend, -64] + stnp A_l, A_h, [dstend, -64] + ldp A_l, A_h, [srcend, -48] + stnp A_l, A_h, [dstend, -48] + ldp A_l, A_h, [srcend, -32] + stnp A_l, A_h, [dstend, -32] + ldp A_l, A_h, [srcend, -16] + stnp A_l, A_h, [dstend, -16] + ret + +END (__memcpy_falkor) +libc_hidden_builtin_def (__memcpy_falkor) +#endif Index: glibc-2.26/sysdeps/aarch64/multiarch/memmove.c =================================================================== --- glibc-2.26.orig/sysdeps/aarch64/multiarch/memmove.c +++ glibc-2.26/sysdeps/aarch64/multiarch/memmove.c @@ -30,9 +30,14 @@ extern __typeof (__redirect_memmove) __l extern __typeof (__redirect_memmove) __memmove_generic attribute_hidden; extern __typeof (__redirect_memmove) __memmove_thunderx attribute_hidden; +extern __typeof (__redirect_memmove) __memmove_falkor attribute_hidden; libc_ifunc (__libc_memmove, - IS_THUNDERX (midr) ? __memmove_thunderx : __memmove_generic); + (IS_THUNDERX (midr) + ? __memmove_thunderx + : (IS_FALKOR (midr) + ? __memmove_falkor + : __memmove_generic))); # undef memmove strong_alias (__libc_memmove, memmove); Index: glibc-2.26/sysdeps/aarch64/multiarch/memmove_falkor.S =================================================================== --- /dev/null +++ glibc-2.26/sysdeps/aarch64/multiarch/memmove_falkor.S @@ -0,0 +1,232 @@ +/* Copyright (C) 2017 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + +/* Assumptions: ARMv8-a, AArch64, falkor, unaligned accesses. */ + +#define dstin x0 +#define src x1 +#define count x2 +#define dstlen x3 +#define dst x3 +#define srcend x4 +#define dstend x5 +#define A_l x6 +#define A_lw w6 +#define A_h x7 +#define A_hw w7 +#define B_l x8 +#define B_lw w8 +#define B_h x9 +#define C_l x10 +#define C_h x11 +#define D_l x12 +#define D_h x13 +#define E_l src +#define E_h count +#define F_l srcend +#define F_h dst +#define tmp1 x14 + +/* Alias with A_l and A_h to train the prefetcher. */ +#define Q_l x22 +#define Q_h x23 + +/* RATIONALE: + + The copy has 4 distinct parts: + * Small copies of 16 bytes and under + * Medium sized copies of 17-96 bytes + * Large copies where the source address is higher than the destination + (forward copies) + * Large copies where the destination address is higher than the source + (copy backward, or move). + + We use only two registerpairs x6,x7 and x22,x23 for the copies and copy 32 + bytes at a time to correctly train the hardware prefetcher for better + throughput. */ +ENTRY_ALIGN (__memmove_falkor, 6) + + sub tmp1, dstin, src + add srcend, src, count + add dstend, dstin, count + cmp count, 96 + ccmp tmp1, count, 2, hi + b.lo L(move_long) + + cmp count, 16 + b.ls L(copy16) + cmp count, 96 + b.hi L(copy_long) + + /* Medium copies: 17..96 bytes. */ + sub tmp1, count, 1 + ldp A_l, A_h, [src] + tbnz tmp1, 6, L(copy96) + ldp D_l, D_h, [srcend, -16] + tbz tmp1, 5, 1f + ldp B_l, B_h, [src, 16] + ldp C_l, C_h, [srcend, -32] + stp B_l, B_h, [dstin, 16] + stp C_l, C_h, [dstend, -32] +1: + stp A_l, A_h, [dstin] + stp D_l, D_h, [dstend, -16] + ret + + .p2align 4 + /* Small copies: 0..16 bytes. */ +L(copy16): + cmp count, 8 + b.lo 1f + ldr A_l, [src] + ldr A_h, [srcend, -8] + str A_l, [dstin] + str A_h, [dstend, -8] + ret + .p2align 4 +1: + /* 4-7 */ + tbz count, 2, 1f + ldr A_lw, [src] + ldr A_hw, [srcend, -4] + str A_lw, [dstin] + str A_hw, [dstend, -4] + ret + .p2align 4 +1: + /* 2-3 */ + tbz count, 1, 1f + ldrh A_lw, [src] + ldrh A_hw, [srcend, -2] + strh A_lw, [dstin] + strh A_hw, [dstend, -2] + ret + .p2align 4 +1: + /* 0-1 */ + tbz count, 0, 1f + ldrb A_lw, [src] + strb A_lw, [dstin] +1: ret + + .p2align 4 + /* Copy 64..96 bytes. Copy 64 bytes from the start and + 32 bytes from the end. */ +L(copy96): + ldp B_l, B_h, [src, 16] + ldp C_l, C_h, [src, 32] + ldp D_l, D_h, [src, 48] + ldp E_l, E_h, [srcend, -32] + ldp F_l, F_h, [srcend, -16] + stp A_l, A_h, [dstin] + stp B_l, B_h, [dstin, 16] + stp C_l, C_h, [dstin, 32] + stp D_l, D_h, [dstin, 48] + stp E_l, E_h, [dstend, -32] + stp F_l, F_h, [dstend, -16] + ret + + /* Align SRC to 16 byte alignment so that we don't cross cache line + boundaries on both loads and stores. There are at least 96 bytes + to copy, so copy 16 bytes unaligned and then align. The loop + copies 32 bytes per iteration and prefetches one iteration ahead. */ + + .p2align 4 +L(copy_long): + sub count, count, 64 + 16 /* Test and readjust count. */ + mov B_l, Q_l + mov B_h, Q_h + ldp A_l, A_h, [src] + and tmp1, src, 15 + bic src, src, 15 + sub dst, dstin, tmp1 + add count, count, tmp1 /* Count is now 16 too large. */ + ldp Q_l, Q_h, [src, 16]! + stp A_l, A_h, [dstin] + ldp A_l, A_h, [src, 16]! + +L(loop64): + subs count, count, 32 + stp Q_l, Q_h, [dst, 16] + ldp Q_l, Q_h, [src, 16]! + stp A_l, A_h, [dst, 32]! + ldp A_l, A_h, [src, 16]! + b.hi L(loop64) + + /* Write the last full set of 32 bytes. The remainder is at most 32 + bytes, so it is safe to always copy 32 bytes from the end even if + there is just 1 byte left. */ +L(last64): + ldp C_l, C_h, [srcend, -32] + stp Q_l, Q_h, [dst, 16] + ldp Q_l, Q_h, [srcend, -16] + stp A_l, A_h, [dst, 32] + stp C_l, C_h, [dstend, -32] + stp Q_l, Q_h, [dstend, -16] + mov Q_l, B_l + mov Q_h, B_h + ret + + .p2align 4 +L(move_long): + cbz tmp1, 3f + + mov B_l, Q_l + mov B_h, Q_h + + /* Align SRCEND to 16 byte alignment so that we don't cross cache line + boundaries on both loads and stores. There are at least 96 bytes + to copy, so copy 16 bytes unaligned and then align. The loop + copies 32 bytes per iteration and prefetches one iteration ahead. */ + + ldp A_l, A_h, [srcend, -16] + and tmp1, srcend, 15 + sub srcend, srcend, tmp1 + ldp Q_l, Q_h, [srcend, -16]! + stp A_l, A_h, [dstend, -16] + sub count, count, tmp1 + ldp A_l, A_h, [srcend, -16]! + sub dstend, dstend, tmp1 + sub count, count, 64 + +1: + subs count, count, 32 + stp Q_l, Q_h, [dstend, -16] + ldp Q_l, Q_h, [srcend, -16]! + stp A_l, A_h, [dstend, -32]! + ldp A_l, A_h, [srcend, -16]! + b.hi 1b + + /* Write the last full set of 32 bytes. The remainder is at most 32 + bytes, so it is safe to always copy 32 bytes from the start even if + there is just 1 byte left. */ +2: + ldp C_l, C_h, [src, 16] + stp Q_l, Q_h, [dstend, -16] + ldp Q_l, Q_h, [src] + stp A_l, A_h, [dstend, -32] + stp C_l, C_h, [dstin, 16] + stp Q_l, Q_h, [dstin] + mov Q_l, B_l + mov Q_h, B_h +3: ret + +END (__memmove_falkor) +libc_hidden_builtin_def (__memmove_falkor) Index: glibc-2.26/sysdeps/unix/sysv/linux/aarch64/cpu-features.c =================================================================== --- glibc-2.26.orig/sysdeps/unix/sysv/linux/aarch64/cpu-features.c +++ glibc-2.26/sysdeps/unix/sysv/linux/aarch64/cpu-features.c @@ -28,6 +28,7 @@ struct cpu_list }; static struct cpu_list cpu_list[] = { + {"falkor", 0x510FC000}, {"thunderxt88", 0x430F0A10}, {"generic", 0x0} }; Index: glibc-2.26/sysdeps/unix/sysv/linux/aarch64/cpu-features.h =================================================================== --- glibc-2.26.orig/sysdeps/unix/sysv/linux/aarch64/cpu-features.h +++ glibc-2.26/sysdeps/unix/sysv/linux/aarch64/cpu-features.h @@ -41,6 +41,9 @@ #define IS_THUNDERX(midr) (MIDR_IMPLEMENTOR(midr) == 'C' \ && MIDR_PARTNUM(midr) == 0x0a1) +#define IS_FALKOR(midr) (MIDR_IMPLEMENTOR(midr) == 'Q' \ + && MIDR_PARTNUM(midr) == 0xc00) + struct cpu_features { uint64_t midr_el1; ++++++ fnmatch-collating-elements.patch ++++++ --- /var/tmp/diff_new_pack.vWDO4C/_old 2017-11-15 16:48:22.380757820 +0100 +++ /var/tmp/diff_new_pack.vWDO4C/_new 2017-11-15 16:48:22.380757820 +0100 @@ -10,22 +10,22 @@ * posix/tst-fnmatch4.c: New file. * posix/tst-fnmatch5.c: New file. -Index: glibc-2.22/posix/Makefile +Index: glibc-2.26/posix/Makefile =================================================================== ---- glibc-2.22.orig/posix/Makefile -+++ glibc-2.22/posix/Makefile -@@ -87,6 +87,7 @@ tests := tstgetopt testfnm runtests run +--- glibc-2.26.orig/posix/Makefile ++++ glibc-2.26/posix/Makefile +@@ -91,6 +91,7 @@ tests := test-errno tstgetopt testfnm r bug-getopt5 tst-getopt_long1 bug-regex34 bug-regex35 \ tst-pathconf tst-getaddrinfo4 tst-rxspencer-no-utf8 \ tst-fnmatch3 bug-regex36 tst-getaddrinfo5 \ + tst-fnmatch4 tst-fnmatch5 \ tst-posix_spawn-fd tst-posix_spawn-setsid \ tst-posix_fadvise tst-posix_fadvise64 \ - tst-sysconf-empty-chroot -Index: glibc-2.22/posix/fnmatch.c + tst-sysconf-empty-chroot tst-glob-tilde +Index: glibc-2.26/posix/fnmatch.c =================================================================== ---- glibc-2.22.orig/posix/fnmatch.c -+++ glibc-2.22/posix/fnmatch.c +--- glibc-2.26.orig/posix/fnmatch.c ++++ glibc-2.26/posix/fnmatch.c @@ -53,7 +53,6 @@ we support a correct implementation only in glibc. */ #ifdef _LIBC @@ -34,11 +34,11 @@ # include "../locale/coll-lookup.h" # include <shlib-compat.h> -Index: glibc-2.22/posix/fnmatch_loop.c +Index: glibc-2.26/posix/fnmatch_loop.c =================================================================== ---- glibc-2.22.orig/posix/fnmatch_loop.c -+++ glibc-2.22/posix/fnmatch_loop.c -@@ -503,26 +503,12 @@ FCT (pattern, string, string_end, no_lea +--- glibc-2.26.orig/posix/fnmatch_loop.c ++++ glibc-2.26/posix/fnmatch_loop.c +@@ -497,26 +497,12 @@ FCT (const CHAR *pattern, const CHAR *st { int32_t table_size; const int32_t *symb_table; @@ -67,7 +67,7 @@ table_size = _NL_CURRENT_WORD (LC_COLLATE, -@@ -534,71 +520,55 @@ FCT (pattern, string, string_end, no_lea +@@ -528,71 +514,55 @@ FCT (const CHAR *pattern, const CHAR *st _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); @@ -180,7 +180,7 @@ } /* Get the collation sequence value. */ -@@ -606,9 +576,9 @@ FCT (pattern, string, string_end, no_lea +@@ -600,9 +570,9 @@ FCT (const CHAR *pattern, const CHAR *st # if WIDE_CHAR_VERSION cold = wextra[1 + wextra[idx]]; # else @@ -192,7 +192,7 @@ cold = *((int32_t *) &extra[idx]); # endif -@@ -618,10 +588,10 @@ FCT (pattern, string, string_end, no_lea +@@ -612,10 +582,10 @@ FCT (const CHAR *pattern, const CHAR *st { /* No valid character. Match it as a single byte. */ @@ -205,7 +205,7 @@ c = *p++; } else -@@ -629,7 +599,6 @@ FCT (pattern, string, string_end, no_lea +@@ -623,7 +593,6 @@ FCT (const CHAR *pattern, const CHAR *st } } else @@ -213,7 +213,7 @@ #endif { c = FOLD (c); -@@ -721,25 +690,11 @@ FCT (pattern, string, string_end, no_lea +@@ -715,25 +684,11 @@ FCT (const CHAR *pattern, const CHAR *st { int32_t table_size; const int32_t *symb_table; @@ -240,7 +240,7 @@ # endif table_size = -@@ -752,51 +707,44 @@ FCT (pattern, string, string_end, no_lea +@@ -746,51 +701,44 @@ FCT (const CHAR *pattern, const CHAR *st _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); @@ -328,7 +328,7 @@ /* Get the collation sequence value. */ is_seqval = 1; # if WIDE_CHAR_VERSION -@@ -804,19 +752,18 @@ FCT (pattern, string, string_end, no_lea +@@ -798,19 +746,18 @@ FCT (const CHAR *pattern, const CHAR *st # else /* Adjust for the alignment. */ idx += 1 + extra[idx]; @@ -351,10 +351,10 @@ } else { -Index: glibc-2.22/posix/tst-fnmatch4.c +Index: glibc-2.26/posix/tst-fnmatch4.c =================================================================== --- /dev/null -+++ glibc-2.22/posix/tst-fnmatch4.c ++++ glibc-2.26/posix/tst-fnmatch4.c @@ -0,0 +1,51 @@ +/* Test for fnmatch handling of collating elements + Copyright (C) 2015 Free Software Foundation, Inc. @@ -407,10 +407,10 @@ + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" -Index: glibc-2.22/posix/tst-fnmatch5.c +Index: glibc-2.26/posix/tst-fnmatch5.c =================================================================== --- /dev/null -+++ glibc-2.22/posix/tst-fnmatch5.c ++++ glibc-2.26/posix/tst-fnmatch5.c @@ -0,0 +1,53 @@ +/* Test for fnmatch handling of collating elements + Copyright (C) 2015 Free Software Foundation, Inc. ++++++ glob-tilde-overflow.patch ++++++ ++++ 2244 lines (skipped) ++++++ malloc-tcache-leak.patch ++++++ 2017-10-06 Carlos O'Donell <[email protected]> [BZ #22111] * malloc/malloc.c (tcache_shutting_down): Use bool type. (tcache_thread_freeres): Set tcache_shutting_down before freeing the tcache. * malloc/Makefile (tests): Add tst-malloc-tcache-leak. * malloc/tst-malloc-tcache-leak.c: New file. Index: glibc-2.26/malloc/Makefile =================================================================== --- glibc-2.26.orig/malloc/Makefile +++ glibc-2.26/malloc/Makefile @@ -34,6 +34,7 @@ tests := mallocbug tst-malloc tst-valloc tst-interpose-nothread \ tst-interpose-thread \ tst-alloc_buffer \ + tst-malloc-tcache-leak \ tests-static := \ tst-interpose-static-nothread \ @@ -242,3 +243,5 @@ tst-dynarray-fail-ENV = MALLOC_TRACE=$(o $(objpfx)tst-dynarray-fail-mem.out: $(objpfx)tst-dynarray-fail.out $(common-objpfx)malloc/mtrace $(objpfx)tst-dynarray-fail.mtrace > $@; \ $(evaluate-test) + +$(objpfx)tst-malloc-tcache-leak: $(shared-thread-library) Index: glibc-2.26/malloc/malloc.c =================================================================== --- glibc-2.26.orig/malloc/malloc.c +++ glibc-2.26/malloc/malloc.c @@ -2940,7 +2940,7 @@ typedef struct tcache_perthread_struct tcache_entry *entries[TCACHE_MAX_BINS]; } tcache_perthread_struct; -static __thread char tcache_shutting_down = 0; +static __thread bool tcache_shutting_down = false; static __thread tcache_perthread_struct *tcache = NULL; /* Caller must ensure that we know tc_idx is valid and there's room @@ -2977,8 +2977,12 @@ tcache_thread_freeres (void) if (!tcache) return; + /* Disable the tcache and prevent it from being reinitialized. */ tcache = NULL; + tcache_shutting_down = true; + /* Free all of the entries and the tcache itself back to the arena + heap for coalescing. */ for (i = 0; i < TCACHE_MAX_BINS; ++i) { while (tcache_tmp->entries[i]) @@ -2990,8 +2994,6 @@ tcache_thread_freeres (void) } __libc_free (tcache_tmp); - - tcache_shutting_down = 1; } text_set_element (__libc_thread_subfreeres, tcache_thread_freeres); Index: glibc-2.26/malloc/tst-malloc-tcache-leak.c =================================================================== --- /dev/null +++ glibc-2.26/malloc/tst-malloc-tcache-leak.c @@ -0,0 +1,112 @@ +/* Bug 22111: Test that threads do not leak their per thread cache. + Copyright (C) 2015-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* The point of this test is to start and exit a large number of + threads, while at the same time looking to see if the used + memory grows with each round of threads run. If the memory + grows above some linear bound we declare the test failed and + that the malloc implementation is leaking memory with each + thread. This is a good indicator that the thread local cache + is leaking chunks. */ + +#include <stdio.h> +#include <stdlib.h> +#include <malloc.h> +#include <pthread.h> +#include <assert.h> + +#include <support/check.h> +#include <support/support.h> +#include <support/xthread.h> + +void * +worker (void *data) +{ + void *ret; + /* Allocate an arbitrary amount of memory that is known to fit into + the thread local cache (tcache). If we have at least 64 bins + (default e.g. TCACHE_MAX_BINS) we should be able to allocate 32 + bytes and force malloc to fill the tcache. We are assuming tcahce + init happens at the first small alloc, but it might in the future + be deferred to some other point. Therefore to future proof this + test we include a full alloc/free/alloc cycle for the thread. We + need a compiler barrier to avoid the removal of the useless + alloc/free. We send some memory back to main to have the memory + freed after the thread dies, as just another check that the chunks + that were previously in the tcache are still OK to free after + thread death. */ + ret = xmalloc (32); + __asm__ volatile ("" ::: "memory"); + free (ret); + return (void *) xmalloc (32); +} + +static int +do_test (void) +{ + pthread_t *thread; + struct mallinfo info_before, info_after; + void *retval; + + /* This is an arbitrary choice. We choose a total of THREADS + threads created and joined. This gives us enough iterations to + show a leak. */ + int threads = 100000; + + /* Avoid there being 0 malloc'd data at this point by allocating the + pthread_t required to run the test. */ + thread = (pthread_t *) xcalloc (1, sizeof (pthread_t)); + + info_before = mallinfo (); + + assert (info_before.uordblks != 0); + + printf ("INFO: %d (bytes) are in use before starting threads.\n", + info_before.uordblks); + + for (int loop = 0; loop < threads; loop++) + { + *thread = xpthread_create (NULL, worker, NULL); + retval = xpthread_join (*thread); + free (retval); + } + + info_after = mallinfo (); + printf ("INFO: %d (bytes) are in use after all threads joined.\n", + info_after.uordblks); + + /* We need to compare the memory in use before and the memory in use + after starting and joining THREADS threads. We almost always grow + memory slightly, but not much. Consider that if even 1-byte leaked + per thread we'd have THREADS bytes of additional memory, and in + general the in-use at the start of main is quite low. We will + always leak a full malloc chunk, and never just 1-byte, therefore + anything above "+ threads" from the start (constant offset) is a + leak. Obviously this assumes no thread-related malloc'd internal + libc data structures persist beyond the thread death, and any that + did would limit the number of times you could call pthread_create, + which is a QoI we'd want to detect and fix. */ + if (info_after.uordblks > (info_before.uordblks + threads)) + FAIL_EXIT1 ("Memory usage after threads is too high.\n"); + + /* Did not detect excessive memory usage. */ + free (thread); + exit (0); +} + +#include <support/test-driver.c> ++++++ math-c++-compat.patch ++++++ --- /var/tmp/diff_new_pack.vWDO4C/_old 2017-11-15 16:48:22.556751371 +0100 +++ /var/tmp/diff_new_pack.vWDO4C/_new 2017-11-15 16:48:22.556751371 +0100 @@ -1,3 +1,18 @@ +2017-10-17 Romain Naour <[email protected]> (tiny change) + + [BZ #22296] + * math/math.h: Let signbit use the builtin in C++ mode with gcc + < 6.x + +2017-10-03 Gabriel F. T. Gomes <[email protected]> + + [BZ #22235] + * sysdeps/ieee754/ldbl-96/bits/iscanonical.h (iscanonical): + Provide a C++ implementation based on function overloading, + rather than using __MATH_TG, which uses C-only builtins. + * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h (iscanonical): + Likewise. + 2017-09-22 Gabriel F. T. Gomes <[email protected]> [BZ #22146] @@ -56,7 +71,23 @@ # define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \ FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x) # else -@@ -442,8 +448,12 @@ enum +@@ -412,6 +418,15 @@ enum + /* Return nonzero value if sign of X is negative. */ + # if __GNUC_PREREQ (6,0) + # define signbit(x) __builtin_signbit (x) ++# elif defined __cplusplus ++ /* In C++ mode, __MATH_TG cannot be used, because it relies on ++ __builtin_types_compatible_p, which is a C-only builtin. ++ The check for __cplusplus allows the use of the builtin instead of ++ __MATH_TG. This is provided for libstdc++, only to let its configure ++ test work. No further use of this definition of signbit is expected ++ in C++ mode, since libstdc++ provides its own version of signbit ++ in cmath (which undefines signbit). */ ++# define signbit(x) __builtin_signbitl (x) + # elif __GNUC_PREREQ (4,0) + # define signbit(x) __MATH_TG ((x), __builtin_signbit, (x)) + # else +@@ -442,8 +457,12 @@ enum /* Return nonzero value if X is positive or negative infinity. */ # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \ @@ -71,7 +102,7 @@ # define isinf(x) \ (__builtin_types_compatible_p (__typeof (x), _Float128) \ ? __isinff128 (x) : __builtin_isinf_sign (x)) -@@ -470,7 +480,32 @@ enum +@@ -470,7 +489,32 @@ enum # include <bits/iscanonical.h> /* Return nonzero value if X is a signaling NaN. */ @@ -105,7 +136,7 @@ /* Return nonzero value if X is subnormal. */ # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL) -@@ -484,15 +519,40 @@ enum +@@ -484,15 +528,40 @@ enum # endif # else /* __cplusplus */ extern "C++" { @@ -182,3 +213,59 @@ # define __HAVE_GENERIC_SELECTION 1 #else # define __HAVE_GENERIC_SELECTION 0 +Index: glibc-2.26/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h +=================================================================== +--- glibc-2.26.orig/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h ++++ glibc-2.26/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h +@@ -37,5 +37,22 @@ extern int __iscanonicall (long double _ + conversion, before being discarded; in IBM long double, there are + encodings that are not consistently handled as corresponding to any + particular value of the type, and we return 0 for those. */ +-# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) +-#endif ++# ifndef __cplusplus ++# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) ++# else ++/* In C++ mode, __MATH_TG cannot be used, because it relies on ++ __builtin_types_compatible_p, which is a C-only builtin. On the ++ other hand, overloading provides the means to distinguish between ++ the floating-point types. The overloading resolution will match ++ the correct parameter (regardless of type qualifiers (i.e.: const ++ and volatile)). */ ++extern "C++" { ++inline int iscanonical (float __val) { return __iscanonicalf (__val); } ++inline int iscanonical (double __val) { return __iscanonical (__val); } ++inline int iscanonical (long double __val) { return __iscanonicall (__val); } ++# if __HAVE_DISTINCT_FLOAT128 ++inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); } ++# endif ++} ++# endif /* __cplusplus */ ++#endif /* __NO_LONG_DOUBLE_MATH */ +Index: glibc-2.26/sysdeps/ieee754/ldbl-96/bits/iscanonical.h +=================================================================== +--- glibc-2.26.orig/sysdeps/ieee754/ldbl-96/bits/iscanonical.h ++++ glibc-2.26/sysdeps/ieee754/ldbl-96/bits/iscanonical.h +@@ -34,4 +34,21 @@ extern int __iscanonicall (long double _ + conversion, before being discarded; in extended precision, there + are encodings that are not consistently handled as corresponding to + any particular value of the type, and we return 0 for those. */ +-#define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) ++#ifndef __cplusplus ++# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) ++#else ++/* In C++ mode, __MATH_TG cannot be used, because it relies on ++ __builtin_types_compatible_p, which is a C-only builtin. On the ++ other hand, overloading provides the means to distinguish between ++ the floating-point types. The overloading resolution will match ++ the correct parameter (regardless of type qualifiers (i.e.: const ++ and volatile)). */ ++extern "C++" { ++inline int iscanonical (float __val) { return __iscanonicalf (__val); } ++inline int iscanonical (double __val) { return __iscanonical (__val); } ++inline int iscanonical (long double __val) { return __iscanonicall (__val); } ++# if __HAVE_DISTINCT_FLOAT128 ++inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); } ++# endif ++} ++#endif /* __cplusplus */ ++++++ nss-files-large-buffers.patch ++++++ ++++ 831 lines (skipped) ++++++ spawni-assert.patch ++++++ 2017-10-23 Adhemerval Zanella <[email protected]> * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Use 0 instead of WNOHANG in waitpid call. 2017-10-20 Adhemerval Zanella <[email protected]> [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 @@ <http://www.gnu.org/licenses/>. */ #include <spawn.h> -#include <assert.h> #include <fcntl.h> #include <paths.h> #include <string.h> @@ -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; ++++++ sysconf-uio-maxiov.patch ++++++ 2017-10-20 Florian Weimer <[email protected]> [BZ #22321] sysconf: Fix missing definition of UIO_MAXIOV on Linux. * sysdeps/posix/sysconf.c: Include <sys/uio.h>. * sysdeps/unix/sysv/linux/Makefile (tests): Add tst-sysconf-iov_max. (tst-sysconf-iov_max): Link with tst-sysconf-iov_max-uapi.o. * sysdeps/unix/sysv/linux/tst-sysconf-iov_max.c: New file. * sysdeps/unix/sysv/linux/tst-sysconf-iov_max-uapi.c: Likewise. Index: glibc-2.26/sysdeps/posix/sysconf.c =================================================================== --- glibc-2.26.orig/sysdeps/posix/sysconf.c +++ glibc-2.26/sysdeps/posix/sysconf.c @@ -29,6 +29,7 @@ #include <sys/stat.h> #include <sys/sysinfo.h> #include <sys/types.h> +#include <sys/uio.h> #include <regex.h> #define NEED_SPEC_ARRAY 0 Index: glibc-2.26/sysdeps/unix/sysv/linux/Makefile =================================================================== --- glibc-2.26.orig/sysdeps/unix/sysv/linux/Makefile +++ glibc-2.26/sysdeps/unix/sysv/linux/Makefile @@ -50,7 +50,7 @@ sysdep_headers += sys/mount.h sys/acct.h bits/siginfo-arch.h bits/siginfo-consts-arch.h tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ - tst-quota tst-sync_file_range test-errno-linux + tst-quota tst-sync_file_range test-errno-linux tst-sysconf-iov_max # Generate the list of SYS_* macros for the system calls (__NR_* macros). @@ -120,7 +120,11 @@ ifndef no_deps -include $(objpfx)bits/syscall.d endif generated += bits/syscall.h bits/syscall.d -endif + +# Separate object file for access to the constant from the UAPI header. +$(objpfx)tst-sysconf-iov_max: $(objpfx)tst-sysconf-iov_max-uapi.o + +endif # $(subdir) == misc ifeq ($(subdir),time) sysdep_headers += sys/timex.h bits/timex.h Index: glibc-2.26/sysdeps/unix/sysv/linux/tst-sysconf-iov_max-uapi.c =================================================================== --- /dev/null +++ glibc-2.26/sysdeps/unix/sysv/linux/tst-sysconf-iov_max-uapi.c @@ -0,0 +1,27 @@ +/* Check IOV_MAX definition: Helper function to capture UAPI header value. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Use a separate function to avoid header compatibility issues. */ + +#include <linux/uio.h> + +long +uio_maxiov_value (void) +{ + return UIO_MAXIOV; +} Index: glibc-2.26/sysdeps/unix/sysv/linux/tst-sysconf-iov_max.c =================================================================== --- /dev/null +++ glibc-2.26/sysdeps/unix/sysv/linux/tst-sysconf-iov_max.c @@ -0,0 +1,40 @@ +/* Check IOV_MAX definition for consistency (bug 22321). + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Defined in tst-sysconf-iov_max-uapi.c. */ +long uio_maxiov_value (void); + + +#include <limits.h> +#include <support/check.h> +#include <sys/uio.h> +#include <unistd.h> + +static int +do_test (void) +{ + TEST_VERIFY (_XOPEN_IOV_MAX == 16); /* Value required by POSIX. */ + TEST_VERIFY (uio_maxiov_value () >= _XOPEN_IOV_MAX); + TEST_VERIFY (IOV_MAX == uio_maxiov_value ()); + TEST_VERIFY (UIO_MAXIOV == uio_maxiov_value ()); + TEST_VERIFY (sysconf (_SC_UIO_MAXIOV) == uio_maxiov_value ()); + TEST_VERIFY (sysconf (_SC_IOV_MAX) == uio_maxiov_value ()); + return 0; +} + +#include <support/test-driver.c>
