about summary refs log tree commit diff
path: root/sysdeps/unix/sysv
Commit message (Collapse)AuthorAgeFilesLines
* Add fesetexcept.Joseph Myers2016-08-1626-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TS 18661-1 defines an fesetexcept function for setting floating-point exception flags without the side-effect of causing enabled traps to be taken. This patch series implements this function for glibc. The present patch adds the fallback stub implementation, x86 and x86_64 implementations, documentation, tests and ABI baseline updates. The remaining patches, some of them untested, add implementations for other architectures. The implementations generally follow those of the fesetexceptflag function. As for fesetexceptflag, the approach taken for architectures where setting flags causes enabled traps to be taken is to set the flags (and potentially cause traps) rather than refusing to set the flags and returning an error. Since ISO C and TS 18661 provide no way to enable traps, this is formally in accordance with the standards. The NEWS entry should be considered a placeholder, since this patch series is intended to be followed by further such series adding other TS 18661-1 features, so that the NEWS entry would end up looking more like * New <fenv.h> features from TS 18661-1:2014 are added to libm: the fesetexcept, fetestexceptflag, fegetmode and fesetmode functions, the femode_t type and the FE_DFL_MODE macro. with hopefully more such entries for other features, rather than having an entry for a single function in the end. I believe we have consensus for adding TS 18661-1 interfaces as per <https://sourceware.org/ml/libc-alpha/2016-06/msg00421.html>. Tested for x86_64, x86, mips64 (hard float, and soft float to test the fallback version), arm (hard float) and powerpc (hard float, soft float and e500). * math/fesetexcept.c: New file. * sysdeps/i386/fpu/fesetexcept.c: Likewise. * sysdeps/x86_64/fpu/fesetexcept.c: Likewise. * math/fenv.h: Define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION and include <bits/libc-header-start.h> instead of including <features.h>. [__GLIBC_USE (IEC_60559_BFP_EXT)] (fesetexcept): New function declaration. * manual/arith.texi (fesetexcept): Document function. * math/Versions (fesetexcept): New libm symbol at version GLIBC_2.25. * math/Makefile (libm-support): Add fesetexcept. (tests): Add test-fesetexcept and test-fesetexcept-traps. * math/test-fesetexcept.c: New file. * math/test-fesetexcept-traps.c: Likewise. * sysdeps/nacl/libm.abilist: Update. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
* arm: mark __startcontext as .cantunwind (bug 20435)Andreas Schwab2016-08-151-0/+7
| | | | | __startcontext marks the bottom of the call stack of the contexts created by makecontext.
* x86: Use sysdep.o from libc.a in static librariesFlorian Weimer2016-08-041-0/+2
| | | | | | | | | Static libraries can use the sysdep.o copy in libc.a without a performance penalty. This results in a visible difference if libpthread.a is relinked into a single object file (which is needed to support libraries which check for the presence of certain symbols to enable threading support, which generally fails with static linking unless libpthread.a is relinked).
* Minimize sysdeps code involved in defining major/minor/makedev.Zack Weinberg2016-08-0331-106/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Presently sys/sysmacros.h is entirely defined in sysdeps. This would mean that the deprecation logic coming up in the next patch would have to be written twice (in generic/ and unix/sysv/linux/). To avoid that, hoist all but the unavoidably system-dependent logic to misc/, leaving a bits/ header behind. This also promotes the Linux-specific encoding of dev_t, which accommodates 32-bit major and minor numbers in a 64-bit dev_t, to generic, as glibc's dev_t is always 64 bits wide. The former Linux implementation used inline functions to avoid evaluating arguments more than once. After this change, all platforms use inline functions, which means that three new symbols are added to the generic ABI. (These symbols are in the user namespace, which is how they have always been on Linux. They begin with "gnu_dev_", so collisions with user code are pretty unlikely.) New ports henceforth need only provide a bits/sysmacros.h defining internal macros __SYSMACROS_{DECLARE,DEFINE}_{MAJOR,MINOR,MAKEDEV}. This is only necessary if the kernel encoding is incompatible with the now-generic encoding (for instance, it would be necessary for FreeBSD). While I was at it, I added a basic round-trip test for these functions. * sysdeps/generic/sys/sysmacros.h: Delete file. * sysdeps/unix/sysv/linux/makedev.c: Delete file. * sysdeps/unix/sysv/linux/sys/sysmacros.h: Move file ... * bits/sysmacros.h: ... here; this encoding is now the generic encoding. Now defines only the following macros: __SYSMACROS_DECLARE_MAJOR, __SYSMACROS_DEFINE_MAJOR, __SYSMACROS_DECLARE_MINOR, __SYSMACROS_DEFINE_MINOR, __SYSMACROS_DECLARE_MAKEDEV, __SYSMACROS_DEFINE_MAKEDEV. * misc/sys/sysmacros.h, misc/makedev.c: New files that use bits/sysmacros.h and the above new macros to generate the public implementations of major, minor, and makedev. * misc/tst-makedev.c: New test. * include/sys/sysmacros.h: New wrapper. * misc/Makefile (headers): Add sys/sysmacros.h, bits/sysmacros.h. (routines): Add makedev. (tests): Add tst-makedev. * misc/Versions [GLIBC_2.25]: Add gnu_dev_major, gnu_dev_minor, gnu_dev_makedev. * posix/Makefile (headers): Remove sys/sysmacros.h. * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove makedev. * sysdeps/arm/nacl/libc.abilist: Add GLIBC_2.25, gnu_dev_major, gnu_dev_makedev, gnu_dev_minor. * sysdeps/unix/sysv/linux/aarch64/libc.abilist * sysdeps/unix/sysv/linux/alpha/libc.abilist * sysdeps/unix/sysv/linux/arm/libc.abilist * sysdeps/unix/sysv/linux/hppa/libc.abilist * sysdeps/unix/sysv/linux/i386/libc.abilist * sysdeps/unix/sysv/linux/ia64/libc.abilist * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist * sysdeps/unix/sysv/linux/microblaze/libc.abilist * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist * sysdeps/unix/sysv/linux/nios2/libc.abilist * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist * sysdeps/unix/sysv/linux/sh/libc.abilist * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist * sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Add GLIBC_2.25.
* Define PF_QIPCRTR, AF_QIPCRTR from Linux 4.7 in bits/socket.h.Joseph Myers2016-08-031-1/+3
| | | | | | | | | | | | This patch adds the new PF_QIPCRTR and AF_QIPCRTR from Linux 4.7 to sysdeps/unix/sysv/linux/bits/socket.h. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). * sysdeps/unix/sysv/linux/bits/socket.h (PF_QIPCRTR): New macro. (PF_MAX): Update value. (AF_QIPCRTR): New macro.
* Nios II localplt.data update: remove __eqsf2Chung-Lin Tang2016-07-271-1/+0
|
* powerpc: Fix missing verb and typo in comment about AT_HWCAP entryGustavo Romero2016-07-211-2/+2
| | | | | Fix missing verb and typo in comment about AT_HWCAP entry, in the context of mcontext_t struct definition for PPC64 Linux kernels.
* microblaze: fix variable name collision with syscall macrosMike Frysinger2016-07-191-21/+21
| | | | | | | | | If a function passes in a variable named "ret", the code will miscompile when it declares a local ret variable. In some cases, it's even a build failure like so: ../sysdeps/unix/sysv/linux/spawni.c: In function '__spawni_child': ../sysdeps/unix/sysv/linux/spawni.c:289:5: error: address of register variable 'ret' requested while (write_not_cancel (p, &ret, sizeof ret) < 0)
* Refactor Linux raise implementation (BZ#15368)Adhemerval Zanella2016-07-133-50/+77
| | | | | | | | | | | | | | | | | | | | | | | | | This patch changes both the nptl and libc Linux raise implementation to avoid the issues described in BZ#15368. The strategy used is summarized in bug report first comment: 1. Block all signals (including internal NPTL ones); 2. Get pid and tid directly from syscall (not relying on cached values); 3. Call tgkill; 4. Restore old signal mask. Tested on x86_64 and i686. [BZ #15368] * sysdeps/unix/sysv/linux/nptl-signals.h (__nptl_clear_internal_signals): New function. (__libc_signal_block_all): Likewise. (__libc_signal_block_app): Likewise. (__libc_signal_restore_set): Likewise. * sysdeps/unix/sysv/linux/pt-raise.c (raise): Use Linux raise.c implementation. * sysdeps/unix/sysv/linux/raise.c (raise): Reimplement to not use the cached pid/tid value in pthread structure.
* x86-64: Add p{read,write}[v]64 to syscalls.list [BZ #20348]H.J. Lu2016-07-121-0/+4
| | | | | | | | | | | | | | | | 64-bit off_t in pread64, preadv, pwrite64 and pwritev syscalls is passed in one 64-bit register for both x32 and x86-64. Since the inline asm statement only passes long, which is 32-bit for x32, in registers, 64-bit off_t is truncated to 32-bit on x32. Since __ASSUME_PREADV and __ASSUME_PWRITEV are defined unconditionally, these syscalls can be implemented in syscalls.list to pass 64-bit off_t in one 64-bit register. Tested on x86-64 and x32 with off_t > 4GB on pread64/pwrite64 and preadv64/pwritev64. [BZ #20348] * sysdeps/unix/sysv/linux/x86_64/syscalls.list: Add pread64, preadv64, pwrite64 and pwritev64.
* X86-64: Define LO_HI_LONG to skip pos_h [BZ #20349]H.J. Lu2016-07-111-0/+4
| | | | | | | | | | | | | | | Define LO_HI_LONG to skip pos_h since it is ignored by kernel: static inline loff_t pos_from_hilo(unsigned long high, unsigned long low) { #define HALF_LONG_BITS (BITS_PER_LONG / 2) return (((loff_t)high << HALF_LONG_BITS) << HALF_LONG_BITS) | low; } where size of loff_t == size of long. [BZ #20349] * sysdeps/unix/sysv/linux/x86_64/sysdep.h (LO_HI_LONG): New.
* [AArch64] Add bits/hwcap.h for aarch64 linuxSzabolcs Nagy2016-07-111-0/+34
| | | | | | | | AArch64 uses HWCAP bits but they are not defined in sys/auxv.h. This patch adds a copy of the linux v4.6 arm64 uapi asm/hwcap.h definitions. * sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h: New.
* Fix LO_HI_LONG definitionAdhemerval Zanella2016-07-081-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | The p{read,write}v{64} consolidation patch [1] added a wrong guard for LO_HI_LONG definition. It currently uses both '__WORDSIZE == 64' and 'defined __ASSUME_WORDSIZE64_ILP32' to set the value to be passed in one argument, otherwise it will be split in two. However it fails on MIPS64n32 where syscalls n32 uses the compat implementation in the kernel meaning the off_t arguments are passed in two separate registers. GLIBC already defines a macro for such cases (__OFF_T_MATCHES_OFF64_T), so this patch uses it instead. Checked on x86_64, i686, x32, aarch64, armhf, and s390. * sysdeps/unix/sysv/linux/sysdep.h [__WORDSIZE == 64 || __ASSUME_WORDSIZE64_ILP32] (LO_HI_LONG): Remove guards. * misc/tst-preadvwritev-common.c: New file. * misc/tst-preadvwritev.c: Use tst-preadvwritev-common.c. * misc/tst-preadvwritev64.c: Use tst-preadwritev-common.c and add a check for files larger than 2GB. [1] 4751bbe2ad4d1bfa05774e29376d553ecfe563b0
* Remove __ASSUME_OFF_DIFF_OFF64 definitionAdhemerval Zanella2016-07-089-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes the __ASSUME_OFF_DIFF_OFF64 define introduced in p{read,write} consolidation patch. This define was added based on the idea 32 bits ports would continue to follow previous off{64}_t definition where off_t size differs from off64_t one. However, with recent AArch64/ILP32 patch submission and also with discussion for RISCV kernel interface, 32 bits ports now may aim to use off_t and off64_t with the same size as 64 bits. So current assumption for both p{read,write} and p{read,write}v are not compatible with new type definition. This patch now makes the syscall wrappers to only depend on __OFF_T_MATCHES_OFF64_T to define the default and 64-suffix variant, as follow: <function>.c #ifndef __OFF_T_MATCHES_OFF64_T /* build <function> */ #endif and <function>64.c /* build <function>64 */ #ifdef __OFF_T_MATCHES_OFF64_T weak_alias (fallocate64, fallocate) #endif Tested on x86_64, i686, x32, and armhf. * sysdeps/unix/sysv/linux/mips/kernel-features.h (__ASSUME_OFF_DIFF_OFF64): Remove define. * sysdeps/unix/sysv/linux/pread.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pread): Replace by __OFF_T_MATCHES_OFF64_T. * sysdeps/unix/sysv/linux/pread64.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pread64): Likewise. * sysdeps/unix/sysv/linux/preadv.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (preadv): Likewise. * sysdeps/unix/sysv/linux/preadv64.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (preadv64): Likewise. * sysdeps/unix/sysv/linux/pwrite.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pwrite): Likewise. * sysdeps/unix/sysv/linux/pwrite64.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pwrite64): Likewise. * sysdeps/unix/sysv/linux/pwritev.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pwritev): Likewise. * sysdeps/unix/sysv/linux/pwritev64.c [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pwritev64): Likewise.
* tile: only define __ASSUME_ALIGNED_REGISTER_PAIRS for 32-bitChris Metcalf2016-07-081-1/+3
| | | | | | | | | | The previous uses of this symbol were all in wordsize-32 code. In commit eeddfa91cbb1 ("Consolidate off_t/off64_t syscall argument passing") it was expanded to be used in pread/pwrite. Accordingly, we only define it in 32-bit compilation modes now. Both tilepro and tilegx32 follow this convention for the kernel ABI. tilegx64 follows it for passing 128-bit values, but there are no such ABIs in the kernel.
* SPARC64: update localplt.dataAurelien Jarno2016-07-011-0/+1
| | | | | | | | | | | | | | Commits d81f90cc and 89faa0340 replaced called to __isnan and __isinf by the corresponding GCC builtins. In turns GCC emits calls to _Qp_cmp. We should therefore add _Qp_cmp to localplt.data as otherwise the elf/check-localplt test fails with: Extra PLT reference: libc.so: _Qp_cmp A similar change has already been done for SPARC32 in commit 6ef1cb95. Changelog: * sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data: Add _Qp_cmp.
* MIPS, SPARC: more fixes to the vfork aliases in libpthread.soAurelien Jarno2016-06-273-14/+14
| | | | | | | | | | | | | | | | | | Commit 43c29487 tried to fix the vfork aliases in libpthread.so on MIPS and SPARC, but failed to do it correctly, introducing an ABI change. This patch does the remaining changes needed to align the MIPS and SPARC vfork implementations with the other architectures. That way the the alpha version of pt-vfork.S works correctly for MIPS and SPARC. The changes for alpha were done in 82aab97c. Changelog: * sysdeps/unix/sysv/linux/mips/vfork.S (__vfork): Rename into __libc_vfork. (__vfork) [IS_IN (libc)]: Remove alias. (__libc_vfork) [IS_IN (libc)]: Define as an alias. * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
* Fix p{readv,writev}{64} consolidation implementationAdhemerval Zanella2016-06-215-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the p{readv,writev}{64} consolidation implementation from commits 4e77815 and af5fdf5. Different from pread/pwrite implementation, preadv/pwritev implementation does not require __ALIGNMENT_ARG because kernel syscall prototypes define the high and low part of the off_t, if it is the case, directly (different from pread/pwrite where the architecture ABI for passing 64-bit values must be in consideration for passsing the arguments). It also adds some basic tests for preadv/pwritev. Tested on x86_64, i686, and armhf. * misc/Makefile (tests): Add tst-preadvwritev and tst-preadvwritev64. * misc/tst-preadvwritev.c: New file. * misc/tst-preadvwritev64.c: Likewise. * sysdeps/unix/sysv/linux/preadv.c (preadv): Remove SYSCALL_LL{64} usage. * sysdeps/unix/sysv/linux/preadv64.c (preadv64): Likewise. * sysdeps/unix/sysv/linux/pwritev.c (pwritev): Likewise. * sysdeps/unix/sysv/linux/pwritev64.c (pwritev64): Likewise. * sysdeps/unix/sysv/linux/sysdep.h (LO_HI_LONG): New macro.
* Expand comments in Linux times() implementation.Carlos O'Donell2016-06-191-10/+17
|
* MIPS, SPARC: fix wrong vfork aliases in libpthread.soAurelien Jarno2016-06-183-0/+6
| | | | | | | | | | | | | | | | | | | | | | With recent binutils versions the GNU libc fails to build on at least MISP and SPARC, with this kind of error: /home/aurel32/glibc/glibc-build/nptl/libpthread.so:(*IND*+0x0): multiple definition of `vfork@GLIBC_2.0' /home/aurel32/glibc/glibc-build/nptl/libpthread.so::(.text+0xee50): first defined here It appears that on these architectures pt-vfork.S includes vfork.S (through the alpha version of pt-vfork.S) and that the __vfork aliases are not conditionalized on IS_IN (libc) like on other architectures. Therefore the aliases are also wrongly included in libpthread.so. Fix this by properly conditionalizing the aliases like on other architectures. Changelog: * sysdeps/unix/sysv/linux/mips/vfork.S (__vfork): Conditionalize hidden_def, weak_alias and strong_alias on [IS_IN (libc)]. * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
* Add nextup and nextdown math functionsRajalakshmi Srinivasaraghavan2016-06-1626-0/+182
| | | | | | | | | | | TS 18661 adds nextup and nextdown functions alongside nextafter to provide support for float128 equivalent to it. This patch adds nextupl, nextup, nextupf, nextdownl, nextdown and nextdownf to libm before float128 support. The nextup functions return the next representable value in the direction of positive infinity and the nextdown functions return the next representable value in the direction of negative infinity. These are currently enabled as GNU extensions.
* Remove __ASSUME_FUTEX_LOCK_PIAdhemerval Zanella2016-06-135-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes __ASSUME_FUTEX_LOCK_PI usage and assumes that kernel will correctly return if it supports or not futex_atomic_cmpxchg_inatomic. Current PI mutex code already has runtime support by calling prio_inherit_missing and returns ENOTSUP if the futex operation fails at initialization (it issues a FUTEX_UNLOCK_PI futex operation). Also, current minimum supported kernel (v3.2) will return ENOSYS if futex_atomic_cmpxchg_inatomic is not supported in the system: kernel/futex.c: 2628 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, 2629 u32 __user *uaddr2, u32 val2, u32 val3) 2630 { 2631 int ret = -ENOSYS, cmd = op & FUTEX_CMD_MASK; [...] 2667 case FUTEX_UNLOCK_PI: 2668 if (futex_cmpxchg_enabled) 2669 ret = futex_unlock_pi(uaddr, flags); [...] 2686 return ret; 2687 } The futex_cmpxchg_enabled is initialized by calling cmpxchg_futex_value_locked, which calls futex_atomic_cmpxchg_inatomic. For ARM futex_atomic_cmpxchg_inatomic will be either defined (if both CONFIG_CPU_USE_DOMAINS and CONFIG_SMP are not defined) or use the default generic implementation that returns ENOSYS. For m68k is uses the default generic implementation. For mips futex_atomic_cmpxchg_inatomic will return ENOSYS if cpu has no 'cpu_has_llsc' support (defined by each chip supporte inside kernel). For sparc, 32-bit kernel will just use default generic implementation, while 64-bit kernel has support. Tested on ARM (v3.8 kernel) and x86_64. * nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI] (prio_inherit_missing): Remove define. * sysdeps/unix/sysv/linux/arm/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise. * sysdeps/unix/sysv/linux/m68k/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise. * sysdeps/unix/sysv/linux/mips/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise. * sysdeps/unix/sysv/linux/sparc/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise.
* Revert {send,sendm,recv,recvm}msg conformance changesAdhemerval Zanella2016-06-1059-575/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After some discussion in libc-alpha about this POSIX compliance fix, I see that GLIBC should indeed revert back to previous definition of msghdr and cmsghdr and implementation of sendmsg, recvmsg, sendmmsg, recvmmsg due some reasons: * The possible issue where the syscalls wrapper add the compatibility layer is quite limited in scope and range. And kernel current also add some limits to the values on the internal msghdr and cmsghdr fields: - msghdr::msg_iovlen larger than UIO_MAXIOV (1024) returns EMSGSIZE. - msghdr::msg_controllen larger than INT_MAX returns ENOBUFS. * There is a small performance hit for recvmsg/sendmsg/recmmsg which is neglectable, but it is a big hit for sendmmsg since now instead of calling the syscall for the packed structure, GLIBC is calling multiple sendmsg. This defeat the very existence of the syscall. * It currently breaks libsanitizer build on GCC [1] (I fixed on compiler-rt). However the fix is incomplete because it does add any runtime check since libsanitizer currently does not have any facility to intercept symbols with multiple version [2]. This, along with incorret dlsym/dlvsym return for versioned symbol due another bug [3], makes hard to interpose versioned symbols. Also, current approach of fixing GCC PR#71445 leads to half-baked solutions without versioned symbol interposing. This patch basically reverts commits 2f0dc39029ae08, 222c2d7f4357d66, af7f7c7ec8dea1. I decided to not revert abf29edd4a3918 (Adjust kernel-features.h defaults for recvmsg and sendmsg) mainly because it does not really address the POSIX compliance original issue and also adds some cleanups. Tested on x86, i386, s390, s390x, aarch64, and powerpc64le. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71445 [2] https://github.com/google/sanitizers/issues/628 [3] https://sourceware.org/bugzilla/show_bug.cgi?id=14932 * conform/data/sys/socket.h-data (msghdr.msg_iovlen): Add xfail-. (msghdr.msg_controllen): Likewise. (cmsghdr.cmsg_len): Likewise. * nptl/Makefile (libpthread-routines): Remove ptw-oldrecvmsg and ptw-oldsendmsg. (CFLAGS-oldrecvmsg.c): Remove rule. (CFLAGS-oldsendmsg.c): Likewise. (CFLAGS-recvmsg.c): Add rule. (CFLAGS-sendmsg.c): Likewise. * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove oldrecvmsg, oldsendmsg, oldrecvmmsg, oldsendmmsg. (CFLAGS-recvmsg.c): Remove rule. (CFLAGS-sendmsg.c): Likewise. (CFLAGS-oldrecvmsg.c): Likewise. (CFLAGS-oldsendmsg.c): Likewise. (CFLAGS-recvmmsg.c): Likewise. * sysdeps/unix/sysv/linux/bits/socket.h (msghdr.msg_iovlen): Revert to kernel defined interfaces. (msghdr.msg_controllen): Likewise. (cmsghdr.cmsg_len): Likewise. (msghdr.__glibc_reserved1): Remove member. (msghdr.__glibc_reserved2): Likewise. (cmsghdr.__glibc_reserved1): Likewise. * sysdeps/unix/sysv/linux/oldrecvmmsg.c: Remove file. * sysdeps/unix/sysv/linux/oldrecvmsg.c: Likewise. * sysdeps/unix/sysv/linux/oldsendmmsg.c: Likewise. * sysdeps/unix/sysv/linux/oldsendmsg.c: Likewise. * sysdeps/unix/sysv/linux/recvmmsg.c: Revert back to previous version. * sysdeps/unix/sysv/linux/recvmsg.c: Likewise. * sysdeps/unix/sysv/linux/sendmmsg.c: Likewise. * sysdeps/unix/sysv/linux/sendmsg.c: Likewise. * sysdeps/unix/sysv/linux/aarch64/Versions [libc] (GLIBC_2.24): Remove recvmsg and sendmsg. * sysdeps/unix/sysv/linux/alpha/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/hppa/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/i386/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/m68k/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/microblaze/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/mips/mips32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/nios2/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/powerpc/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sh/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sparc/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/tile/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/x86_64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions: Remove file * sysdeps/unix/sysv/linux/x86_64/64/Versions: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/Versions: Likewise. * sysdeps/unix/sysv/linux/aarch64/libc.abilist: Remove new 2.24 version for {recv,send,recm,sendm}msg. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
* Bug 20214: Fix linux/in6.h and netinet/in.h sync.Carlos O'Donell2016-06-071-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | In: https://sourceware.org/glibc/wiki/Synchronizing_Headers we explain how we synchronize our headers with Linux kernel headers. In order to synchronize with the Linux linux/in6.h and linux/ipv6.h headers we checked for their guard macros and then defined __USE_KERNEL_IPV6_DEFS and conditionalized code on this macro. In upstream kernel 56c176c9 the _UAPI prefix was stripped and this broke our synchronized headers again. We now need to check for _LINUX_IN6_H and _IPV6_H, and keep checking the old versions of the header guard checks for maximum backwards compatibility with older Linux headers (the history is actually a bit muddled here and it appears upstream linus kernel broke this 10 months *before* our fix was ever applied to glibc, but without glibc testing we didn't notice and distro kernels have their own testing to fix this). This patch fixes synchronization with linux/in6.h and with netinet/in.h.
* Bug 20198: quick_exit should not call destructors.Carlos O'Donell2016-06-0628-0/+28
| | | | | | | | | | | | | | | | | | In C++11 18.5.12 says "Objects shall not be destroyed as a result of calling quick_exit." In C11 quick_exit is silent about thread object destruction. Therefore to make glibc C++ compliant we do not call any thread local destructors. A new regression test verifies the fix. I will note that C++11 18.5.3 makes it clear that C++ defines additional requirements for _Exit() to prevent it from executing destructors. Given that the point of _Exit() is to terminate the process immediately it makes sense the C and C++ should line up and avoid calling destructors. No failures. New regtest passes.
* Consolidate pwritev/pwritev64 implementationsAdhemerval Zanella2016-06-068-199/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch consolidates all the pwritev{64} implementation for Linux in only one (sysdeps/unix/sysv/linux/pwritev{64}.c). It also removes the syscall from the auto-generation using assembly macros. It was based on previous pwrite/pwrite64 consolidation patch. The new macro SYSCALL_LL{64} is used to handle the offset argument and alias is created for __ASSUME_OFF_DIFF_OFF64 in case of pread64. Checked on x86_64, i386, aarch64, and powerpc64le. * misc/Makefile (CFLAGS-pwritev.c): New variable: add cancellation required flags. (CFLAGS-pwritev64.c): Likewise. * sysdeps/unix/sysv/linux/generic/wordsize-32/pwritev.c: Remove file. * sysdeps/unix/sysv/linux/generic/wordsize-32/pwritev64.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/pwritev64.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/pwritev.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/pwritev64.: Likwise. * sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list (pwritev): Remove syscall from auto-generation. * sysdeps/unix/sysv/linux/pwritev.c: Rewrite implementation. [WORDSIZE == 64] (pwritev64): Remove macro. [!PWRITEV] (PWRITEV): Likewise. [!PWRITEV] (PWRITEV_REPLACEMENT): Likewise. [!PWRITEV] (PWRITE): Likewise. [!PWRITEV] (OFF_T): Likewise. [!__ASSUME_PWRITEV] (PWRITEV_REPLACEMENT): Likewise. (LO_HI_LONG): Remove macro. [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pwritev): Add function. * sysdeps/unix/sysv/linux/pwritev64.c: Rewrite implementation. (PWRITEV): Remove macro. (PWRITEV_REPLACEMENTE): Likewise. (PWRITE): Likewise. (OFF_T): Likewise. (pwritev64): New function. * nptl/tst-cancel4.c (tf_writev): Add test.
* Consolidate preadv/preadv64 implementationAdhemerval Zanella2016-06-068-200/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch consolidates all the preadv{64} implementation for Linux in only one (sysdeps/unix/sysv/linux/preadv{64}.c). It also removes the syscall from the auto-generation using assembly macros. It was based on previous pread/pread64 consolidation patch. The new macro SYSCALL_LL{64} is used to handle the offset argument and alias is created for __ASSUME_OFF_DIFF_OFF64 in case of pread64. Checked on x86_64, i386, aarch64, and powerpc64le. * misc/Makefile (CFLAGS-preadv.c): New variable: add cancellation required flags. (CFLAGS-preadv64.c): Likewise. * sysdeps/unix/sysv/linux/generic/wordsize-32/preadv.c: Remove file. * sysdeps/unix/sysv/linux/generic/wordsize-32/preadv64.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/preadv64.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/preadv.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/preadv64.: Likwise. * sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list (preadv): Remove syscall from auto-generation. * sysdeps/unix/sysv/linux/preadv.c: Rewrite implementation. [WORDSIZE == 64] (preadv64): Remove macro. [!PREADV] (PREADV): Likewise. [!PREADV] (PREADV_REPLACEMENT): Likewise. [!PREADV] (PREAD): Likewise. [!PREADV] (OFF_T): Likewise. [!__ASSUME_PREADV] (PREADV_REPLACEMENT): Likewise. (LO_HI_LONG): Remove macro. [__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (preadv): Add function. * sysdeps/unix/sysv/linux/preadv64.c: Rewrite implementation. (PREADV): Remove macro. (PREADV_REPLACEMENTE): Likewise. (PREAD): Likewise. (OFF_T): Likewise. (preadv64): New function. * nptl/tst-cancel4.c (tf_preadv): Add test.
* Fix macro API for __USE_KERNEL_IPV6_DEFS.Carlos O'Donell2016-06-021-1/+3
| | | | | | | | | | | | | | | | The use of __USE_KERNEL_IPV6_DEFS with ifndef is bad practice per: https://sourceware.org/glibc/wiki/Wundef. This change moves it to use 'if' and always define the macro. Please note that this is not the only problem with this code. I have a series of fixes after this one to resolve breakage with this code and add regression tests for it via compile-only source testing (to be discussed in another thread). Unfortunately __USE_KERNEL_XATTR_DEFS is set by the kernel and not glibc, and uses 'define', so we can't fix that yet.
* posix: Call _exit in failure case for posix_spawn{p} (BZ#20178)Adhemerval Zanella2016-05-301-1/+1
| | | | | | | | | | | This patch call _exit instead of exit in failure case for the spawned child in Linux posix_spawn{p} implementation. Tested on x86_64. [BZ #20178] * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Call _exit on failure instead of exit.
* network: Fix missing bits from {recv,send}{m}msg standard com,plianceAdhemerval Zanella2016-05-262-2/+2
| | | | | | | | | | | | | | | | | | | This patch fixes wrong/missing bits from the Fix {recv,send}{m}msg standard compliance (BZ#16919) patches: * nptl/Makefile sets CFLAGS-oldrecvfrom.c, but there's no such file as oldrecvfrom.c. It should be oldsendmsg.c as defined by ChangeLog. * sysdeps/unix/sysv/linux/hppa/Versions and sysdeps/unix/sysv/linux/i386/Versions list a symbol recvms instead of recvmsg at version GLIBC_2.24. * nptl/Makefile (CFLAGS-oldrecvfrom.c): Remove rule. (CFLAGS-oldsendmsg.c): Add rule. * sysdeps/unix/sysv/linux/hppa/Versions [libc] (GLIBC_2.24): Correct recvmsg symbol name. * sysdeps/unix/sysv/linux/i386/Versions [libc] (GLIBC_2.24): Likewise.
* network: recvmmsg and sendmmsg standard compliance (BZ#16919)Adhemerval Zanella2016-05-2515-44/+275
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen to be of size int and socklen_t respectively, however Linux implements it as a size_t. So for 64-bits architecture where sizeof of size_t is larger than socklen_t, both sendmmsg and recvmmsg need to adjust the mmsghdr::msg_hdr internal fields before issuing the syscall itself. This patch fixes it by operating on the padding if it the case. For recvmmsg, the most straightfoward case, only zero padding the fields is suffice. However, for sendmmsg, where adjusting the buffer is out of the contract (since it may point to a read-only data), the function is rewritten to use sendmsg instead (which from previous patch allocates a temporary msghdr to operate on). Also for 64-bit ports that requires it, a new recvmmsg and sendmmsg compat version is created (which uses size_t for both cmsghdr::cmsg_len and internal Tested on x86_64, i686, aarch64, armhf, and powerpc64le. * sysdeps/unix/sysv/linux/Makefile [$(subdir) = socket] (sysdep_routines): Add oldrecvmmsg and oldsendmmsg. * sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add recvmmsg and sendmmsg. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/oldrecvmmsg.c: New file. * sysdeps/unix/sysv/linux/oldsendmmsg.c: Likewise. * sysdeps/unix/sysv/linux/recvmmsg.c (__recvmmsg): Adjust msghdr iovlen and controllen fields to adjust to POSIX specification. * sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Likewise.
* network: recvmsg and sendmsg standard compliance (BZ#16919)Adhemerval Zanella2016-05-2560-37/+350
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen to be of size int and socklen_t respectively. However Linux defines it as both size_t and for 64-bit it requires some adjustments to make the functions standard compliance. This patch fixes it by creating a temporary header and zeroing the pad fields for 64-bits architecture where size of size_t exceeds the size of the int. Also the new recvmsg and sendmsg implementation is only added on libc, with libpthread only containing a compat symbol. Tested on x86_64, i686, aarch64, armhf, and powerpc64le. * conform/data/sys/socket.h-data (msghdr.msg_iovlen): Remove xfail- and change to correct expected type. (msghdr.msg_controllen): Likewise. (cmsghdr.cmsg_len): Likewise. * sysdeps/unix/sysv/linux/bits/socket.h (msghdr.msg_iovlen): Fix expected POSIX assumption about the size. (msghdr.msg_controllen): Likewise. (msghdr.__glibc_reserved1): Likewise. (msghdr.__glibc_reserved2): Likewise. (cmsghdr.cmsg_len): Likewise. (cmsghdr.__glibc_reserved1): Likewise. * nptl/Makefile (libpthread-routines): Remove ptw-recvmsg and ptw-sendmsg. Add ptw-oldrecvmsg and ptw-oldsendmsg. (CFLAGS-sendmsg.c): Remove rule. (CFLAGS-recvmsg.c): Likewise. (CFLAGS-oldsendmsg.c): Add rule. (CFLAGS-oldrecvmsg.c): Likewise. * sysdeps/unix/sysv/linux/alpha/Versions [libc] (GLIBC_2.24): Add recvmsg and sendmsg. * sysdeps/unix/sysv/linux/aarch64/Version [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/arm/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/hppa/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/i386/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/ia64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/m68k/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/microblaze/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/mips/mips32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/nios2/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/powerpc/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sh/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sparc/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/Versions [libc] (GLIBC_2.24): Likewise. ( sysdeps/unix/sysv/linux/tile/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions [libc] (GLIBC_2.24): Likewise. ( sysdeps/unix/sysv/linux/x86_64/64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/x84_64/Versions [libc] (GLIBC_2.24): Likewise. * sysdeps/unix/sysv/linux/Makefile [$(subdir) = socket)] (sysdep_headers): Add oldrecvmsg and oldsendmsg. (CFLAGS-sendmsg.c): Add rule. (CFLAGS-recvmsg.c): Likewise. (CFLAGS-oldsendmsg.c): Likewise. (CFLAGS-oldrecvmsg.c): Likewise. * sysdeps/unix/sysv/linux/check_native.c (__check_native): Fix msghdr initialization. * sysdeps/unix/sysv/linux/check_pf.c (make_request): Likewise. * sysdeps/unix/sysv/linux/ifaddrs.c (__netlink_request): Likewise. * sysdeps/unix/sysv/linux/oldrecvmsg.c: New file. * sysdeps/unix/sysv/linux/oldsendmsg.c: Likewise. * sysdeps/unix/sysv/linux/recvmsg.c (__libc_recvmsg): Adjust msghdr iovlen and controllen fields to adjust to POSIX specification. * sysdeps/unix/sysv/linux/sendmsg.c (__libc_sendmsg): Likewise. * sysdeps/unix/sysv/linux/aarch64/libc.abilist: New version and added recvmsg and sendmsg. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdepe/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. Likewise. Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise. Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
* Adjust kernel-features.h defaults for recvmsg and sendmsgAdhemerval Zanella2016-05-2515-28/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes the auto-generation for recvmsg and sendmsg syscall and adjust the kernel-features.h for all architectures supported on Linux. This patch follows the idea of 'Adjust kernel-features.h defaults for socket syscalls.' (35ade9f11b9007ee9683529f2d33698ff35255c8) by define __ASSUME_SENDMSG_SYSCALL and __ASSUME_RECVMSG_SYSCALL as supported by default and undefine it for the architecture that do not support it directly. The main rationale is to make is easier add code wrapper over the syscall to fix BZ#16919 (recvmsg standard compliance). Tested on x86_64, i686, aarch64, armhf, and powerpc64le. * sysdeps/unix/sysv/linux/alpha/syscalls.list (recvmsg): Remove from auto-generation. (sendmsg): Likewise. * sysdeps/unix/sysv/linux/arm/syscalls.list (recvmsg): Likewise. (sendmsg): Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list (recvmsg): Likewise. (sendmsg): Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list (recvmsg): Likewise. (sendmsg): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (recvmsg): Likewise. (sendmsg): Likewise. * sysdeps/unix/sysv/linux/mips/syscalls.list (recvmsg): Likewise. (sendmsg): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list (recvmsg): Likewise. (sendmsg): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (recvmsg): Likewise. (sendmsg): Likewise. * sysdeps/unix/sysv/linux/i386/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL): Remove. [__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL): Likewise. [__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL): Undefine. [__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_SENDMSG_SYSCALL): Define. (__ASSUME_RECVMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/m68k/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL): Remove. [__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL): Likewise. [__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL): Undefine. [__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/s390/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL): Remove. [__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL): Likewise. [__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL): Undefine. [__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/microblaze/kernel-features.h (__ASSUME_SENDMSG_SYSCALL): Undefine. (__ASSUME_RECVMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/powerpc/kernel-features.h (__ASSUME_SENDMSG_SYSCALL): Likewise. (__ASSUME_RECVMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/sh/kernel-features.h (__ASSUME_SENDMSG_SYSCALL): Likewise. (__ASSUME_RECVMSG_SYSCALL): Likewise.
* Make padding in struct sockaddr_storage explicit [BZ #20111]Florian Weimer2016-05-232-4/+46
| | | | | | | | | | This avoids aliasing issues with GCC 6 in -fno-strict-aliasing mode. (With implicit padding, not all data is copied.) This change makes it explicit that struct sockaddr_storage is only 126 bytes large on m68k (unlike elsewhere, where we end up with the requested 128 bytes). The new test case makes sure that this does not happen on other architectures.
* Update sysdeps/unix/sysv/linux/bits/socket.h for Linux 4.6.Joseph Myers2016-05-231-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch updates sysdeps/unix/sysv/linux/bits/socket.h for new constants added in Linux 4.6. AF_KCM / PF_KCM are added. SOL_KCM is new, and I added a lot of SOL_* values postdating the last one present in the header, since I saw no apparent reason for the set in glibc to stop at SOL_IRDA. MSG_BATCH is added; Linux also has MSG_SENDPAGE_NOTLAST which is not in glibc, but given the comment starts "sendpage() internal" I presume it's correct for it not to be in glibc. (Note that this is a case where the Linux kernel header with userspace relevant values is *not* a uapi header but include/linux/socket.h - I don't know why, but at least this header, as well as uapi headers, needs reviewing for glibc-relevant changes each release.) Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). * sysdeps/unix/sysv/linux/bits/socket.h (PF_KCM): New macro. (PF_MAX): Update value. (AF_KCM): New macro. (SOL_NETBEUI): Likewise. (SOL_LLC): Likewise. (SOL_DCCP): Likewise. (SOL_NETLINK): Likewise. (SOL_TIPC): Likewise. (SOL_RXRPC): Likewise. (SOL_PPPOL2TP): Likewise. (SOL_BLUETOOTH): Likewise. (SOL_PNPIPE): Likewise. (SOL_RDS): Likewise. (SOL_IUCV): Likewise. (SOL_CAIF): Likewise. (SOL_ALG): Likewise. (SOL_NFC): Likewise. (SOL_KCM): Likewise. (MSG_BATCH): New enum value and macro.
* Don't call internal _Unwind_Resume via PLTH.J. Lu2016-05-182-2/+2
| | | | | | | | | | | There is no need to call the internal funtion, _Unwind_Resume, which is defined in unwind-forcedunwind.c, via PLT. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S (__condvar_cleanup2): Remove JUMPTARGET from _Unwind_Resume call. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S (__condvar_cleanup1): Likewise.
* Don't call internal __pthread_unwind via PLTH.J. Lu2016-05-181-2/+4
| | | | | | | | | | | | Add PTHREAD_UNWIND to replace JUMPTARGET(__pthread_unwind) and define it to __GI___pthread_unwind within libpthread. * sysdeps/unix/sysv/linux/x86_64/cancellation.S (PTHREAD_UNWIND): New (__pthread_unwind): Renamed to ... (PTHREAD_UNWIND): This. (__pthread_enable_asynccancel): Replace JUMPTARGET(__pthread_unwind) with PTHREAD_UNWIND.
* Add CLONE_NEWCGROUP from Linux 4.6 to bits/sched.h.Joseph Myers2016-05-181-0/+1
| | | | | | | | | | | This patch adds CLONE_NEWCGROUP, new in Linux 4.6, to sysdeps/unix/sysv/linux/bits/sched.h. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). * sysdeps/unix/sysv/linux/bits/sched.h [__USE_GNU] (CLONE_NEWCGROUP): New macro.
* Add Q_GETNEXTQUOTA from Linux 4.6 to sys/quota.h.Joseph Myers2016-05-181-0/+1
| | | | | | | | | | | This patch adds Q_GETNEXTQUOTA, new in Linux 4.6, to sysdeps/unix/sysv/linux/sys/quota.h. Tested for x86_64 and x86 (testsuite, and that installed shared libraries are unchanged by the patch). * sysdeps/unix/sysv/linux/sys/quota.h [_LINUX_QUOTA_VERSION >= 2] (Q_GETNEXTQUOTA): New macro.
* S390: Add support for vdso getcpu symbol.Stefan Liebler2016-05-094-0/+10
| | | | | | | | This patch adds support for symbol __kernel_getcpu in vDSO, which is available with kernel 4.5. Now sched_getcpu is using this symbol if available in mapped vDSO by defining macro HAVE_GETCPU_VSYSCALL. If not available at runtime, the former syscall is used.
* CVE-2016-1234: glob: Do not copy d_name field of struct dirent [BZ #19779]Florian Weimer2016-05-041-0/+22
| | | | | | Instead, we store the data we need from the return value of readdir in an object of the new type struct readdir_result. This type is independent of the layout of struct dirent.
* powerpc: Add missing insn in swapcontext [BZ #20004]Paul E. Murphy2016-05-031-0/+1
| | | | | A missing instruction was discovered in the compat version of swapcontext while running the GCC test suite.
* powerpc: Fix clone CLONE_VM compareAdhemerval Zanella2016-05-021-1/+1
| | | | | | | | | | | | This patch fixes the clone CLONE_VM change from 0cb313f (BZ#19957) where the commit changed the register that contains the save flags argument to compare with (from r28 to r29). This patch changes back to correct register. Tested on powerpc32 (thanks to Tulio Magno Quites Machado Filho). * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S (__clone): Fix flags CLONE_VM compare.
* m68k: avoid local labels in symbol tableAndreas Schwab2016-04-301-4/+4
|
* Fix clone (CLONE_VM) pid/tid reset (BZ#19957)Adhemerval Zanella2016-04-2921-141/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in libc-alpha [1] current clone with CLONE_VM (without CLONE_THREAD set) will reset the pthread pid/tid fields to -1. The issue is since memory is shared between the parent and child it will clobber parent's cached pid/tid leading to internal inconsistencies if the value is not restored. And even it is restored it may lead to racy conditions when between set/restore a thread might invoke pthread function that validate the pthread with INVALID_TD_P/INVALID_NOT_TERMINATED_TD_P and thus get wrong results. As stated in BZ19957, previously reports of this behaviour was close with EWONTFIX due the fact usage of clone outside glibc is tricky since glibc requires consistent internal pthread, while using clone directly may not provide it. However since now posix_spawn uses clone (CLONE_VM) to fixes various issues related to previous vfork usage this issue requires fixing. The vfork implementation also does something similar, but instead it negates and restores only the *pid* field and functions that might access its value know to handle such case (getpid, raise and pthread ones that uses INVALID_TD_P/INVALID_NOT_TERMINATED_TD_P macros that check only *tid* field). Also vfork does not call __clone directly, instead calling either __NR_vfork or __NR_clone directly. So this patch removes this clone behavior by avoiding setting the pthread pid/tid field for CLONE_VM. There is no need to check for CLONE_THREAD, since the minimum supported kernel in all architecture implies that CLONE_VM must be used with CLONE_THREAD, otherwise clone returns EINVAL. Instead of current approach of: int clone(int (*fn)(void *), void *child_stack, int flags, ...) [...] if (flags & CLONE_THREAD) goto do_syscall; pid_t new_value; if (flags & CLONE_VM) new_value = -1; else new_value = getpid (); THREAD_SETMEM (THREAD_SELF, pid, new_value); THREAD_SETMEM (THREAD_SELF, tid, new_value); do_syscall: [...] The new approach uses: int clone(int (*fn)(void *), void *child_stack, int flags, ...) [...] if (flags & CLONE_VM) goto do_syscall; pid_t new_value = getpid (); THREAD_SETMEM (THREAD_SELF, pid, new_value); THREAD_SETMEM (THREAD_SELF, tid, new_value); do_syscall: [...] It also removes the linux tst-getpid2.c test which expects the previous behavior and instead add another clone test. Tested on x86_64, i686, x32, powerpc64le, aarch64, armhf, s390, and s390x. I also did limited check on mips32 and sparc64 (using the new added test). I also got reviews from both m68k, hppa, and tile. So I presume for these architecture the patch works. The fixes for alpha, microblaze, sh, ia64, and nio2 have not been tested. [1] https://sourceware.org/ml/libc-alpha/2016-04/msg00307.html * sysdeps/unix/sysv/linux/Makefile [$(subdir) == nptl] (test): Remove tst-getpid2. (test): Add tst-clone2. * sysdeps/unix/sysv/linux/tst-clone2.c: New file. * sysdeps/unix/sysv/linux/aarch64/clone.S (__clone): Do not change pid/tid fields for CLONE_VM. * sysdeps/unix/sysv/linux/arm/clone.S: Likewise. * sysdeps/unix/sysv/linux/i386/clone.S: Likewise. * sysdeps/unix/sysv/linux/mips/clone.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise. * sysdeps/unix/sysv/linux/tst-getpid2.c: Remove file.
* Add missing iucv related defines.Stefan Liebler2016-04-271-0/+10
| | | | | | | | | | | this patch adds the missing SOL_IUCV socket level definition and socket options SO_IPRMDATA_MSG, SO_MSGLIMIT, SO_MSGSIZE which can be used with get/setsockopt(). SCM_IUCV_TRGCLS is needed to send/receive ancillary data with send/recvmsg(). The defines are copied from kernel-source: include/net/iucv/af_iucv.h include/linux/socket.h
* Fix stdlib/tst-makecontext regression for Nios IIChung-Lin Tang2016-04-251-0/+12
|
* Fix pread consolidation on ports that require argument alignmentAdhemerval Zanella2016-04-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the __ALIGNMENT_{ARG,COUNT} definition for ports that define __ASSUME_ALIGNED_REGISTER_PAIRS by including the kernel-features.h (where it is defined if the case). This was shown on arm with failing cases: FAIL: debug/tst-chk1 FAIL: debug/tst-chk2 FAIL: debug/tst-chk3 FAIL: debug/tst-chk4 FAIL: debug/tst-chk5 FAIL: debug/tst-chk6 FAIL: debug/tst-lfschk1 FAIL: debug/tst-lfschk2 FAIL: debug/tst-lfschk3 FAIL: debug/tst-lfschk4 FAIL: debug/tst-lfschk5 FAIL: debug/tst-lfschk6 FAIL: posix/tst-preadwrite FAIL: posix/tst-preadwrite64 The patches fixes it. Tested on armhf. * sysdeps/unix/sysv/linux/sysdep.h: Include kernel-features.h.
* Remove union wait [BZ #19613]Florian Weimer2016-04-141-1/+1
| | | | | | | The overloading approach in the W* macros was incompatible with integer expressions of a type different from int. Applications using union wait and these macros will have to migrate to the POSIX-specified int status type.
* VDSO support for MIPSMatthew Fortune2016-04-127-0/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for using the implementations of gettimeofday() and clock_gettime() provided by the kernel in the VDSO. The VDSO will always provide clock_gettime() as CLOCK_{REALTIME,MONOTONIC}_COARSE can be implemented regardless of platform. CLOCK_{REALTIME,MONOTONIC}, along with gettimeofday(), are only implemented on platforms which make use of either the CP0 count or GIC as their clocksource. On other platforms, the VDSO does not provide the __vdso_gettimeofday symbol, as it is never useful. The VDSO functions return ENOSYS when they encounter an unsupported request, in which case glibc should fall back to the standard syscall. Tested with upstream kernel 4.5 and QEMU emulating Malta. ./vdsotest gettimeofday bench gettimeofday: syscall: 1021 nsec/call gettimeofday: libc: 262 nsec/call gettimeofday: vdso: 174 nsec/call * sysdeps/unix/sysv/linux/mips/Makefile (sysdep_routines): Include dl-vdso. * sysdeps/unix/sysv/linux/mips/Versions: Add __vdso_clock_gettime. * sysdeps/unix/sysv/linux/mips/init-first.c: New file. * sysdeps/unix/sysv/linux/mips/libc-vdso.h: New file. * sysdeps/unix/sysv/linux/mips/mips32/sysdep.h: (INTERNAL_VSYSCALL_CALL): Define to be compatible with MIPS definitions of INTERNAL_SYSCALL_{ERROR_P,ERRNO}. (HAVE_CLOCK_GETTIME_VSYSCALL): Define. (HAVE_GETTIMEOFDAY_VSYSCALL): Define. * sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h: Likewise.