about summary refs log tree commit diff
path: root/sysdeps/unix
Commit message (Collapse)AuthorAgeFilesLines
* Assume __NR_openat is always definedAurelien Jarno2016-03-231-4/+0
| | | | | | | | | With the 2.6.32 minimum kernel on x86 and 3.2 on other architectures, __NR_openat is always defined. Changelog: * sysdeps/unix/sysv/linux/dl-openat64.c (openat64) [__NR_openat]: Make code unconditional.
* x86, pthread_cond_*wait: Do not depend on %eax not being clobberedNick Alcock2016-03-232-0/+2
| | | | | | | | | | | | | | | | | | | | | | The x86-specific versions of both pthread_cond_wait and pthread_cond_timedwait have (in their fall-back-to-futex-wait slow paths) calls to __pthread_mutex_cond_lock_adjust followed by __pthread_mutex_unlock_usercnt, which load the parameters before the first call but then assume that the first parameter, in %eax, will survive unaffected. This happens to have been true before now, but %eax is a call-clobbered register, and this assumption is not safe: it could change at any time, at GCC's whim, and indeed the stack-protector canary checking code clobbers %eax while checking that the canary is uncorrupted. So reload %eax before calling __pthread_mutex_unlock_usercnt. (Do this unconditionally, even when stack-protection is not in use, because it's the right thing to do, it's a slow path, and anything else is dicing with death.) * sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S: Reload call-clobbered %eax on retry path. * sysdeps/unix/sysv/linux/i386/pthread_cond_wait.S: Likewise.
* Remove __ASSUME_GETDENTS64_SYSCALL.Joseph Myers2016-03-222-114/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes the __ASSUME_GETDENTS64_SYSCALL macro, as its definition is constant given the new kernel version requirements (and was constant anyway before those requirements except for MIPS n32). Note that the "#ifdef __NR_getdents64" conditional *is* still needed, because MIPS n64 only has the getdents syscall (being a 64-bit ABI, that syscall is 64-bit; the difference between the two on 64-bit architectures is where d_type goes). If MIPS n64 were to gain the getdents64 syscall and we wanted to use it conditionally on the kernel version at runtime we'd have to revert this patch, but I think that's unlikely (and in any case, we could follow the simpler approach of undefining __NR_getdents64 if the syscall can't be assumed, just like we do for accept4 / recvmmsg / sendmmsg syscalls on architectures where socketcall support came first). Most of the getdents.c changes are reindentation. Tested for x86_64 and x86 that installed stripped shared libraries are unchanged by the patch. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_GETDENTS64_SYSCALL): Remove macro. * sysdeps/unix/sysv/linux/getdents.c [!__ASSUME_GETDENTS64_SYSCALL]: Remove conditional code. [!have_no_getdents64_defined]: Likewise. (__GETDENTS): Remove __have_no_getdents64 conditional.
* Remove __ASSUME_SIGNALFD4.Joseph Myers2016-03-212-26/+1
| | | | | | | | | | | | | | | | Current Linux kernel version requirements mean the signalfd4 syscall can always be assumed to be available. This patch removes __ASSUME_SIGNALFD4 and associated conditionals. Tested for x86_64 and x86 that installed stripped shared libraries are unchanged by the patch. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_SIGNALFD4): Remove macro. * sysdeps/unix/sysv/linux/signalfd.c: Do not include <kernel-features.h>. (signalfd) [__NR_signalfd4]: Make code unconditional. (signalfd) [!__ASSUME_SIGNALFD4]: Remove conditional code.
* posix: Fix posix_spawn implict check styleAdhemerval Zanella2016-03-211-1/+1
| | | | | | | | | | This patch fixes the implicit check style add in 2a69f853c for the general convention one. Checked on x86_64. * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Fix implict checks style.
* Use JUMPTARGET in x86-64 pthreadH.J. Lu2016-03-213-7/+3
| | | | | | | | | | | | | When PLT may be used, JUMPTARGET should be used instead calling the function directly. * sysdeps/unix/sysv/linux/x86_64/cancellation.S (__pthread_enable_asynccancel): Use JUMPTARGET to call __pthread_unwind. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S (__condvar_cleanup2): Use JUMPTARGET to call _Unwind_Resume. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S (__condvar_cleanup1): Likewise.
* posix: Fix posix_spawn invalid memory accessAdhemerval Zanella2016-03-201-1/+1
| | | | | | | | | | | | | Current Linux posix_spawn spawn do not test if the pid argument is valid before trying to update it for success case. This patch fixes it. Tested on x86_64 and i686. * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Fix invalid memory access where posix_spawn success and pid argument is null. * posix/tst-spawn.c (do_test): Add posix_spawn null pid argument for success case.
* Remove __ASSUME_EVENTFD2, move eventfd to syscalls.list.Joseph Myers2016-03-173-52/+1
| | | | | | | | | | | | | | | | Given current Linux kernel version requirements, we can assume the presence of the eventfd2 syscall. This means that __ASSUME_EVENTFD2 can be removed, and a syscalls.list entry suffices for eventfd instead of needing a .c file. This patch implements those changes. Tested for x86_64 and x86 (not that that means much, given the lack of testsuite coverage for eventfd). * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_EVENTFD2): Remove macro. * sysdeps/unix/sysv/linux/eventfd.c: Remove file. * sysdeps/unix/sysv/linux/syscalls.list (eventfd): New syscall entry.
* Remove __ASSUME_FALLOCATE.Joseph Myers2016-03-172-36/+12
| | | | | | | | | | | | | | | | Given current Linux kernel version requirements, we can always assume the fallocate syscall to be available. This patch removes __ASSUME_FALLOCATE and a test for whether __NR_fallocate is defined. Tested for x86_64 and x86 that installed stripped shared libraries are unchanged by the patch. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_FALLOCATE): Remove macro. * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c: Do not include <kernel-features.h>. [!__ASSUME_FALLOCATE]: Remove conditional code. (posix_fallocate) [__NR_fallocate]: Make code unconditional.
* Remove __ASSUME_PPOLL.Joseph Myers2016-03-152-29/+1
| | | | | | | | | | | | | | | | | | With current kernel version requirements, the ppoll Linux syscall can be assumed to be present on all architectures; this patch removes the __ASSUME_PPOLL macro and conditionals on it and on whether __NR_ppoll is defined. (Note that the same can't yet be done for pselect, because MicroBlaze only wired that up in the syscall table in 3.15.) Tested for x86_64 and x86 that installed stripped shared libraries are unchanged by the patch. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_PPOLL): Remove macro. * sysdeps/unix/sysv/linux/ppoll.c: Do not include <kernel-features.h>. [__NR_ppoll]: Make code unconditional. [!__ASSUME_PPOLL]: Remove conditional code.
* Adjust kernel-features.h defaults for socket syscalls.Joseph Myers2016-03-1517-174/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adjusts the defaults for kernel-features.h macros relating to availability of accept4, recvmmsg and sendmmsg. It is not intended to affect which macros end up getting defined in any configuration. At present, all architectures with syscalls for those functions need to define __ASSUME_*_SYSCALL macros; in particular, any new architecture needs its own kernel-features.h file for that purpose, though it may not otherwise need such a header. Those macros are then used together with __ASSUME_SOCKETCALL to define macros for whether the functions in question are available. This patch changes the defaults so that the syscalls are assumed to be available by default with recent-enough kernels, and it is the responsibility of architecture headers to undefine the macros if they are unavailable in supported kernels at least as recent as the version where the architecture-independent functionality was introduced. The __ASSUME_<function> macros are defaulted similarly instead of being defined based on other macros (defining based on other macros would no longer work because the #undefs appear after the generic header is included), so where the syscall being unavailable means the function is unavailable this means the architecture header has to undefine the __ASSUME_<function> macro; this only affects __ASSUME_ACCEPT4 for ia64, as other cases where the syscalls were added late enough to be relevant with current kernel version requirements are all on socketcall architectures. As a consequence, the AArch64 and Nios II kernel-features.h header files are removed, and others simplified. When the minimum kernel version becomes 4.3 or later on all architectures, the syscalls in question can just be assumed unconditionally, permitting further simplification. Tested for x86_64, x86 and powerpc (that installed shared libraries are unchanged by the patch, and testsuite for x86_64 and x86). * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Define unconditionally. (__ASSUME_ACCEPT4): Likewise. [__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL): Define. [__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG): Likewise. [__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL): Likewise. [__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG): Likewise. * sysdeps/unix/sysv/linux/aarch64/kernel-features.h: Remove file. * sysdeps/unix/sysv/linux/nios2/kernel-features.h: Likewise. * sysdeps/unix/sysv/linux/alpha/kernel-features.h (__ASSUME_RECVMMSG_SYSCALL): Do not define. (__ASSUME_ACCEPT4_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/arm/kernel-features.h (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_ACCEPT4_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/hppa/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Likewise. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/i386/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL): Likewise. [__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL): Likewise. (__ASSUME_ACCEPT4_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION < 0x040300] instead of defining if [__LINUX_KERNEL_VERSION >= 0x040300]. * sysdeps/unix/sysv/linux/ia64/kernel-features.h (__ASSUME_RECVMMSG_SYSCALL): Do not define. (__ASSUME_SENDMMSG_SYSCALL): Likewise. (__ASSUME_ACCEPT4_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION < 0x030300] instead of defining if [__LINUX_KERNEL_VERSION >= 0x030300]. [__LINUX_KERNEL_VERSION < 0x030300] (__ASSUME_ACCEPT4): Undefine. * sysdeps/unix/sysv/linux/m68k/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION < 0x040300] instead of defining if [__LINUX_KERNEL_VERSION >= 0x040300]. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/microblaze/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Do not define. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION < 0x030300] instead of defining if [__LINUX_KERNEL_VERSION >= 0x030300]. * sysdeps/unix/sysv/linux/mips/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Do not define. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/powerpc/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Likewise. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/s390/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Undefine if [__LINUX_KERNEL_VERSION < 0x040300] instead of defining if [__LINUX_KERNEL_VERSION >= 0x040300]. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/sh/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Do not define. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/sparc/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Likewise. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/tile/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Likewise. (__ASSUME_RECVMMSG_SYSCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL): Likewise. * sysdeps/unix/sysv/linux/x86_64/kernel-features.h (__ASSUME_ACCEPT4_SYSCALL): Likewise. [__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL): Likewise. [__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL): Likewise.
* Update glibc headers for Linux 4.5.Joseph Myers2016-03-143-0/+4
| | | | | | | | | | | | | | | This patch updates the glibc headers with the defines MADV_FREE, IPV6_HDRINCL and EPOLLEXCLUSIVE that are added in Linux 4.5. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). * bits/mman-linux.h [__USE_MISC] (MADV_FREE): New macro. * sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_MISC] (MADV_FREE): Likewise. * sysdeps/unix/sysv/linux/bits/in.h (IPV6_HDRINCL): Likewise. * sysdeps/unix/sysv/linux/sys/epoll.h (enum EPOLL_EVENTS): Add EPOLLEXCLUSIVE.
* Add _arch_/_cpu_ to index_*/bit_* in x86 cpu-features.hH.J. Lu2016-03-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | index_* and bit_* macros are used to access cpuid and feature arrays o struct cpu_features. It is very easy to use bits and indices of cpuid array on feature array, especially in assembly codes. For example, sysdeps/i386/i686/multiarch/bcopy.S has HAS_CPU_FEATURE (Fast_Rep_String) which should be HAS_ARCH_FEATURE (Fast_Rep_String) We change index_* and bit_* to index_cpu_*/index_arch_* and bit_cpu_*/bit_arch_* so that we can catch such error at build time. [BZ #19762] * sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h (EXTRA_LD_ENVVARS): Add _arch_ to index_*/bit_*. * sysdeps/x86/cpu-features.c (init_cpu_features): Likewise. * sysdeps/x86/cpu-features.h (bit_*): Renamed to ... (bit_arch_*): This for feature array. (bit_*): Renamed to ... (bit_cpu_*): This for cpu array. (index_*): Renamed to ... (index_arch_*): This for feature array. (index_*): Renamed to ... (index_cpu_*): This for cpu array. [__ASSEMBLER__] (HAS_FEATURE): Add and use field. [__ASSEMBLER__] (HAS_CPU_FEATURE)): Pass cpu to HAS_FEATURE. [__ASSEMBLER__] (HAS_ARCH_FEATURE)): Pass arch to HAS_FEATURE. [!__ASSEMBLER__] (HAS_CPU_FEATURE): Replace index_##name and bit_##name with index_cpu_##name and bit_cpu_##name. [!__ASSEMBLER__] (HAS_ARCH_FEATURE): Replace index_##name and bit_##name with index_arch_##name and bit_arch_##name.
* mips: terminate the FDE before the return trampoline in makecontextAurelien Jarno2016-03-091-0/+7
| | | | | | | | | | | | | | | | | In makecontext the FDE needs to be terminated before the return trampoline otherwise backtrace called within a context created by makecontext yields infinite backtrace. This bug has been present for a long time, stdlib/tst-makecontext did not fail until recent commit e535ce25. Tested on mips-linux-gnu and mips64el-linux-gnuabi64 and mips-linux-gnu, no regression. This fixes stdlib/tst-makecontext on MIPS. Changelog: [BZ #19792] * sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext): Terminate FDE before return label.
* posix: New Linux posix_spawn{p} implementationAdhemerval Zanella2016-03-0721-0/+436
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements a new posix_spawn{p} implementation for Linux. The main difference is it uses the clone syscall directly with CLONE_VM and CLONE_VFORK flags and a direct allocated stack. The new stack and start function solves most the vfork limitation (possible parent clobber due stack spilling). The remaning issue are related to signal handling: 1. That no signal handlers must run in child context, to avoid corrupt parent's state. 2. Child must synchronize with parent to enforce stack deallocation and to possible return execv issues. The first one is solved by blocking all signals in child, even NPTL-internal ones (SIGCANCEL and SIGSETXID). The second issue is done by a stack allocation in parent and a synchronization with using a pipe or waitpid (in case or error). The pipe has the advantage of allowing the child signal an exec error (checked with new tst-spawn2 test). There is an inherent race condition in pipe2 usage for architectures that do not support the syscall directly. In such cases the a pipe plus fctnl is used instead and it may lead to file descriptor leak in parent (as decribed by fcntl documentation). The child process stack is allocate with a mmap with MAP_STACK flag using default architecture stack size. Although it is slower than use a stack buffer from parent, it allows some slack for the compatibility code to run scripts with no shebang (which may use a buffer with size depending of argument list count). Performance should be similar to the vfork default posix implementation and way faster than fork path (vfork on mostly linux ports are basically clone with CLONE_VM plus CLONE_VFORK). The only difference is the syscalls required for the stack allocation/deallocation. It fixes BZ#10354, BZ#14750, and BZ#18433. Tested on i386, x86_64, powerpc64le, and aarch64. [BZ #14750] [BZ #10354] [BZ #18433] * include/sched.h (__clone): Add hidden prototype. (__clone2): Likewise. * include/unistd.h (__dup): Likewise. * posix/Makefile (tests): Add tst-spawn2. * posix/tst-spawn2.c: New file. * sysdeps/posix/dup.c (__dup): Add hidden definition. * sysdeps/unix/sysv/linux/aarch64/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/alpha/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/arm/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/hppa/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/i386/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/ia64/clone2.S (__clone): Likewise. * sysdeps/unix/sysv/linux/m68k/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/microblaze/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/mips/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/nios2/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/sh/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/tile/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/x86_64/clone.S (__clone): Likewise. * sysdeps/unix/sysv/linux/nptl-signals.h (____nptl_is_internal_signal): New function. * sysdeps/unix/sysv/linux/spawni.c: New file.
* Or bit_Prefer_MAP_32BIT_EXEC in EXTRA_LD_ENVVARSH.J. Lu2016-03-031-1/+1
| | | | | | | | | We should turn on bit_Prefer_MAP_32BIT_EXEC in EXTRA_LD_ENVVARS without overriding other bits. [BZ #19758] * sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h (EXTRA_LD_ENVVARS): Or bit_Prefer_MAP_32BIT_EXEC.
* Call x86-64 __setcontext directlyH.J. Lu2016-03-011-1/+1
| | | | | | | | | | | Since x86-64 __start_context calls the internal __setcontext: 5089: 00000000000417e0 145 FUNC LOCAL DEFAULT 13 __setcontext it should call __setcontext directly. * sysdeps/unix/sysv/linux/x86_64/__start_context.S (__start_context): Call __setcontext directly.
* Remove kernel-features.h conditionals on pre-3.2 kernels.Joseph Myers2016-02-2611-157/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch follows up on the increase in minimum kernel version by removing conditionals in non-x86, non-x86_64 kernel-features.h headers that are now constant for all supported kernel versions. * sysdeps/unix/sysv/linux/alpha/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional. [__LINUX_KERNEL_VERSION >= 0x030200]: Likewise. [__LINUX_KERNEL_VERSION < 0x020621]: Remove conditional code. * sysdeps/unix/sysv/linux/arm/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional. [__LINUX_KERNEL_VERSION >= 0x020624]: Likewise. [__LINUX_KERNEL_VERSION >= 0x030000]: Likewise. * sysdeps/unix/sysv/linux/hppa/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020622]: Likewise. [__LINUX_KERNEL_VERSION >= 0x030100]: Likewise. [__LINUX_KERNEL_VERSION < 0x020625]: Remove conditional code. * sysdeps/unix/sysv/linux/ia64/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional. [__LINUX_KERNEL_VERSION >= 0x030000]: Likewise. * sysdeps/unix/sysv/linux/m68k/kernel-features.h [__LINUX_KERNEL_VERSION < 0x030000]: Remove conditional code. * sysdeps/unix/sysv/linux/microblaze/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional. [__LINUX_KERNEL_VERSION < 0x020621]: Remove conditional code. [__LINUX_KERNEL_VERSION < 0x020625]: Likewise. * sysdeps/unix/sysv/linux/mips/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional. [__LINUX_KERNEL_VERSION >= 0x030100]: Likewise. [_MIPS_SIM == _ABIN32 && __LINUX_KERNEL_VERSION < 0x020623]: Remove conditional code. * sysdeps/unix/sysv/linux/powerpc/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020625]: Make code unconditional. [__LINUX_KERNEL_VERSION >= 0x030000]: Likewise. * sysdeps/unix/sysv/linux/sh/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020625]: Likewise. [__LINUX_KERNEL_VERSION >= 0x030000]: Likewise. [__LINUX_KERNEL_VERSION < 0x020625]: Remove conditional code. * sysdeps/unix/sysv/linux/sparc/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x020621]: Make code unconditional. [__LINUX_KERNEL_VERSION >= 0x030000]: Likewise. * sysdeps/unix/sysv/linux/tile/kernel-features.h [__LINUX_KERNEL_VERSION >= 0x030000]: Likewise.
* Remove linux/fanotify.h configure test.Joseph Myers2016-02-243-62/+0
| | | | | | | | | | | | | | | | Now we require Linux 3.2 or later kernel headers everywhere, the configure test for <linux/fanotify.h> is obsolete; this patch removes it. Tested for x86_64. * sysdeps/unix/sysv/linux/configure.ac (linux/fanotify.h): Do not test for header. * sysdeps/unix/sysv/linux/configure: Regenerated. * config.h.in (HAVE_LINUX_FANOTIFY_H): Remove #undef. * sysdeps/unix/sysv/linux/tst-fanotify.c [!HAVE_LINUX_FANOTIFY_H]: Remove conditional code. [HAVE_LINUX_FANOTIFY_H]: Make code unconditional.
* Require Linux 3.2 except on x86 / x86_64, 3.2 headers everywhere.Joseph Myers2016-02-246-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In <https://sourceware.org/ml/libc-alpha/2016-01/msg00885.html> I proposed a minimum Linux kernel version of 3.2 for glibc 2.24, since Linux 2.6.32 has reached EOL. In the discussion in February, some concerns were expressed about compatibility with OpenVZ containers. It's not clear that these are real issues, given OpenVZ backporting kernel features and faking the kernel version for guest software, as discussed in <https://sourceware.org/ml/libc-alpha/2016-02/msg00278.html>. It's also not clear that supporting running GNU/Linux distributions from late 2016 (at the earliest) on a kernel series from 2009 is a sensible expectation. However, as an interim step, this patch increases the requirement everywhere except x86 / x86_64 (since the controversy was only about those architectures); the special caveats and settings can easily be removed later when we're ready to increase the requirements on x86 / x86_64 (and if someone would like to raise the issue on LWN as suggested in the previous discussion, that would be welcome). 3.2 kernel headers are required everywhere by this patch. (x32 already requires 3.4 or later, so is unaffected by this patch.) As usual for such a change, this patch only changes the configure scripts and associated documentation. The intent is to follow up with removal of dead __LINUX_KERNEL_VERSION conditionals. Each __ASSUME_* or other macro that becomes dead can then be removed independently. Tested for x86_64 and x86. * sysdeps/unix/sysv/linux/configure.ac (LIBC_LINUX_VERSION): Define to 3.2.0. (arch_minimum_kernel): Likewise. * sysdeps/unix/sysv/linux/configure: Regenerated. * sysdeps/unix/sysv/linux/i386/configure.ac (arch_minimum_kernel): Define to 2.6.32. * sysdeps/unix/sysv/linux/i386/configure: Regenerated. * sysdeps/unix/sysv/linux/x86_64/64/configure.ac (arch_minimum_kernel): Define to 2.6.32. * sysdeps/unix/sysv/linux/x86_64/64/configure: Regenerated. * README: Document Linux 3.2 requirement. * manual/install.texi (Linux): Document Linux 3.2 headers requirement. * INSTALL: Regenerated.
* Fix MIPS mmap negative offset handling for consistency (bug 19550).Joseph Myers2016-02-016-2/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The handling of negative offsets in MIPS mmap is inconsistent with other architectures, as shown by failure of the test posix/tst-mmap-offset for o32 and n32. The MIPS mmap syscall uses a signed argument and does a signed arithmetic shift on it, whereas the glibc semantics expected by that test are for the offset to be considered as a large positive offset. This patch makes MIPS consistent with other architectures as far as possible by using the mmap2 syscall on o32 (#including the generic implementation), and making mmap not an alias for mmap64 for n32, with a custom implementation for n32 that zero-extends the offset argument to 64-bit before calling the mmap syscall. Tested for MIPS64 (o32, n32, n64). [BZ #19550] * sysdeps/unix/sysv/linux/mips/mips32/mmap.c: New file. * sysdeps/unix/sysv/linux/mips/mips64/mmap64.c: Move to .... * sysdeps/unix/sysv/linux/mips/mips64/n64/mmap64.c: ... here. * sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c: New file. * sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list (mmap64): New syscall entry. * sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list (mmap): New syscall entry. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (mmap): Remove syscall entry.
* Update localplt.data for 32-bit sparc.David S. Miller2016-01-261-0/+1
| | | | * sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data: Add _Q_cmp.
* Define __sqrtl_finite on sparc 32-bit with correct symbol version.David S. Miller2016-01-251-1/+1
| | | | | | | * sysdeps/sparc/sparc32/Versions (GLIBC_2.23): Add entry for __sqrtl_finite. * sysdeps/sparc/sparc32/fpu/e_sqrtl.c (__sqrtl_finite): Define instead using versioned_symbol. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Fix ordering of entries.
* Adjust sparc 32-bit __sqrtl_finite version tag.David S. Miller2016-01-251-1/+1
| | | | | * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Move __sqrtl_finite to GLIBC_2.23
* Cleanup ppc bits/ipc.hPaul E. Murphy2016-01-251-24/+0
| | | | | Ages ago (commit e9dcb08) the ipc syscalls were inlined and eventually abstracted away any need for direct __ipc calls.
* Fix missing __sqrtl_finite symbol in libm on sparc 32-bit.David S. Miller2016-01-241-0/+1
| | | | | | * sysdeps/sparc/sparc32/fpu/e_sqrtl.c: New file. * sysdeps/sparc/sparc32/soft-fp/q_sqrt.c (__ieee754_sqrtl): Remove alias. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Add __sqrtl_finite.
* MIPS: Set the required Linux kernel version to 4.5.0 for 2008 NaNMaciej W. Rozycki2016-01-252-8/+2
| | | | | | | | | | | Complement the addition of the required kernel support, present upstream as from commit 2b5e869ecfcb3112f7e1267cb0328f3ff6d49b18 ("MIPS: ELF: Interpret the NAN2008 file header flag") and released with Linux 4.5-rc1 on Jan 24th, 2016. * sysdeps/unix/sysv/linux/mips/configure.ac: Set `arch_minimum_kernel' to 4.5.0 if 2008 NaN encoding is used. * sysdeps/unix/sysv/linux/mips/configure: Regenerate.
* powerpc: Fix macro usage of htm builtinsPaul E. Murphy2016-01-221-3/+3
| | | | | | Some extraneous semicolons were included in a recent patch which causes a build failure with newer compilers.
* Maintainence patch for nios2: update ULPS file and localplt.data changes.Chung-Lin Tang2016-01-211-0/+5
|
* 2016-01-20 Paul Pluzhnikov <ppluzhnikov@google.com>Paul Pluzhnikov2016-01-202-11/+6
| | | | | | | | | [BZ #19490] * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S (pthread_cond_broadcast): Use ENTRY/END * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S (pthread_cond_signal): Likewise * sysdeps/x86_64/nptl/pthread_spin_lock.S (pthread_spin_lock): Likewise * sysdeps/x86_64/nptl/pthread_spin_trylock.S (pthread_spin_trylock): Likewise * sysdeps/x86_64/nptl/pthread_spin_unlock.S (pthread_spin_unlock): Likewise
* Update localplt.data for powerpc-nofpu.Joseph Myers2016-01-201-2/+2
| | | | | | | | | | | | | | | | | | Testing for powerpc-nofpu showed that localplt.data was out of date. Two new soft-fp functions showed up in the list: __gtsf2 and __unordsf2; this patch adds these as optional. __signbit and __signbitl no longer appear as local PLT entries; given the move to __builtin_signbit* for all GCC versions supported for building glibc (and given the use of the type-generic signbit macro within glibc), those can safely be removed from the list, which this patch does. Tested for powerpc-nofpu. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/localplt.data (__gtsf2): Add as optional for libc.so. (__unordsf2): Likewise. (__signbit): Remove for libc.so. (__signbitl): Likewise.
* sparc: mman.h: fix bad comment insertionMike Frysinger2016-01-161-1/+1
| | | | | The MCL_ONFAULT define was inserted into the middle of a comment which breaks the build.
* New pthread_barrier algorithm to fulfill barrier destruction requirements.Torvald Riegel2016-01-152-348/+0
| | | | | | | | | | The previous barrier implementation did not fulfill the POSIX requirements for when a barrier can be destroyed. Specifically, it was possible that threads that haven't noticed yet that their round is complete still access the barrier's memory, and that those accesses can happen after the barrier has been legally destroyed. The new algorithm does not have this issue, and it avoids using a lock internally.
* Add new header definitions from Linux 4.4 (plus older ptrace definitions).Joseph Myers2016-01-1210-7/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds some new header definitions from Linux 4.4: * MCL_ONFAULT is added to bits/mman.h / bits/mman-linux.h (this was already done for hppa). * PTRACE_SECCOMP_GET_FILTER is added to sys/ptrace.h. Along with it, the older PTRACE_GETSIGMASK and PTRACE_SETSIGMASK, added in Linux 3.11 but missed at the time, are also added. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). * bits/mman-linux.h [!MCL_CURRENT] (MCL_ONFAULT): New macro. * sysdeps/unix/sysv/linux/alpha/bits/mman.h (MCL_ONFAULT): Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/mman.h (MCL_ONFAULT): Likewise. * sysdeps/unix/sysv/linux/sparc/bits/mman.h (MCL_ONFAULT): Likewise. * sysdeps/unix/sysv/linux/sys/ptrace.h (PTRACE_GETSIGMASK): New enum constant and macro. (PTRACE_SETSIGMASK): Likewise. (PTRACE_SECCOMP_GET_FILTER): Likewise. * sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (PTRACE_GETSIGMASK): Likewise. (PTRACE_SETSIGMASK): Likewise. (PTRACE_SECCOMP_GET_FILTER): Likewise. * sysdeps/unix/sysv/linux/ia64/sys/ptrace.h (PTRACE_GETSIGMASK): Likewise. (PTRACE_SETSIGMASK): Likewise. (PTRACE_SECCOMP_GET_FILTER): Likewise. * sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h (PTRACE_GETSIGMASK): Likewise. (PTRACE_SETSIGMASK): Likewise. (PTRACE_SECCOMP_GET_FILTER): Likewise. * sysdeps/unix/sysv/linux/s390/sys/ptrace.h (PTRACE_GETSIGMASK): Likewise. (PTRACE_SETSIGMASK): Likewise. (PTRACE_SECCOMP_GET_FILTER): Likewise. * sysdeps/unix/sysv/linux/sparc/sys/ptrace.h (PTRACE_GETSIGMASK): Likewise. (PTRACE_SETSIGMASK): Likewise. (PTRACE_SECCOMP_GET_FILTER): Likewise. * sysdeps/unix/sysv/linux/tile/sys/ptrace.h (PTRACE_GETSIGMASK): Likewise. (PTRACE_SETSIGMASK): Likewise. (PTRACE_SECCOMP_GET_FILTER): Likewise.
* powerpc: Enforce compiler barriers on hardware transactionsTulio Magno Quites Machado Filho2016-01-084-10/+41
| | | | | | | Work around a GCC behavior with hardware transactional memory built-ins. GCC doesn't treat the PowerPC transactional built-ins as compiler barriers, moving instructions past the transaction boundaries and altering their atomicity.
* xstat: only check to see if __ASSUME_ST_INO_64_BIT is definedMike Frysinger2016-01-074-4/+4
| | | | | | | | We define __ASSUME_ST_INO_64_BIT by default for Linux targets, and then undef it for alpha/sh targets. But the code that uses it looks at its value (as 0/1) rather than whether it's defined (like all other assume knobs). Change the code to see if it's defined to fix build Wundef build errors for alpha/sh.
* Make shebang interpreter directives consistentMarko Myllynen2016-01-071-1/+1
|
* Update copyright dates not handled by scripts/update-copyrights.Joseph Myers2016-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've updated copyright dates in glibc for 2016. This is the patch for the changes not generated by scripts/update-copyrights and subsequent build / regeneration of generated files. * NEWS: Update copyright dates. * catgets/gencat.c (print_version): Likewise. * csu/version.c (banner): Likewise. * debug/catchsegv.sh: Likewise. * debug/pcprofiledump.c (print_version): Likewise. * debug/xtrace.sh (do_version): Likewise. * elf/ldconfig.c (print_version): Likewise. * elf/ldd.bash.in: Likewise. * elf/pldd.c (print_version): Likewise. * elf/sotruss.sh: Likewise. * elf/sprof.c (print_version): Likewise. * iconv/iconv_prog.c (print_version): Likewise. * iconv/iconvconfig.c (print_version): Likewise. * locale/programs/locale.c (print_version): Likewise. * locale/programs/localedef.c (print_version): Likewise. * login/programs/pt_chown.c (print_version): Likewise. * malloc/memusage.sh (do_version): Likewise. * malloc/memusagestat.c (print_version): Likewise. * malloc/mtrace.pl: Likewise. * manual/libc.texinfo: Likewise. * nptl/version.c (banner): Likewise. * nscd/nscd.c (print_version): Likewise. * nss/getent.c (print_version): Likewise. * nss/makedb.c (print_version): Likewise. * posix/getconf.c (main): Likewise. * scripts/test-installation.pl: Likewise. * sysdeps/unix/sysv/linux/lddlibc4.c (main): Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2016-01-041465-1465/+1465
|
* hppa: Add MAP_HUGETLB and MAP_STACK defines [BZ #19285]Helge Deller2016-01-021-13/+8
| | | | | | | | | The attached patch adds some upstream defines like MAP_HUGETLB and MAP_STACK in mman.h for the hppa architecture. The existing MADV_xxK_PAGES defines were dropped upstream, because they were originally added many years ago based on a proposed patch for the Linux kernel which was never applied. So, this patch drops those unneeded defines.
* Fix linux personality syscall wrapperDmitry V. Levin2015-12-3115-3/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The personality system call, starting with linux kernel commit v2.6.29-6609-g11d06b2a1e5658f448a308aa3beb97bacd64a940, always successfully changes the personality if requested. The syscall wrapper, however, still can return an error in the following cases: - the value returned by the system call looks like an error due to architecture limitations of 32-bit kernels; - a personality greater than 0xffffffff is passed to the system call, and the 64-bit kernel does not have commit v2.6.35-rc1-372-g485d527686850d68a0e9006dd9904f19f122485e that would truncate this value to unsigned int; - on sparc64, the value returned by the system call looks like an error due to sparc64 kernel sign extension bug. The solution is three-fold: - move generic syscalls.list personality entry to generic 64-bit syscalls.list file; - for each 32-bit architecture that use negated errno semantics, add a NOERRNO personality entry to their syscalls.list file; - for sparc64 and 32-bit architectures that use dedicated registers to flag syscall errors, add a wrapper around personality syscall; if the system call return value is flagged as an error, this wrapper returns the negated "would be errno" value, otherwise it returns the system call return value; on sparc64, it also truncates the personality argument to unsigned int before passing it to the kernel. [BZ #19408] * sysdeps/unix/sysv/linux/personality.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc64/personality.c: Likewise. * sysdeps/unix/sysv/linux/tst-personality.c: Likewise. * sysdeps/unix/sysv/linux/Makefile [$(subdir) == misc] (sysdep_routines): Add personality. (tests): Add tst-personality. * sysdeps/unix/sysv/linux/syscalls.list (personality): Move ... * sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: ... here. * sysdeps/unix/sysv/linux/arm/syscalls.list (personality): New entry. * sysdeps/unix/sysv/linux/hppa/syscalls.list (personality): Likewise. * sysdeps/unix/sysv/linux/i386/syscalls.list (personality): Likewise. * sysdeps/unix/sysv/linux/m68k/syscalls.list (personality): Likewise. * sysdeps/unix/sysv/linux/microblaze/syscalls.list (personality): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list (personality): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list (personality): Likewise. * sysdeps/unix/sysv/linux/sh/syscalls.list (personality): Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list (personality): Likewise.
* Cleanup ARM ioperm implementation (step 2)Aurelien Jarno2015-12-302-93/+3
| | | | | | | | | | | | | | | | | | Since GLIBC requires a minimum 2.6.32 kernel, the sysctl (CTL_BUS, CTL_BUS_ISA, ISA_*) is always available. We can therefore remove the fallback code reading /etc/arm_systype or parsing /proc/cpuinfo. Remove fscanf from localplt.data as it is no longer called from within GLIBC. * sysdeps/unix/sysv/linux/arm/ioperm.c: Do not include <string.h>. (PATH_ARM_SYSTYPE): Remove. (PATH_CPUINFO): Likewise. (IO_BASE_FOOTBRIDGE): Likewise. (IO_SHIFT_FOOTBRIDGE): Likewise. (struct platform): Likewise. (init_iosys): Remove compatibility code for 2.4 kernels. * sysdeps/unix/sysv/linux/arm/localplt.data: Remove fscanf.
* Do not violate mutex destruction requirements.Torvald Riegel2015-12-232-4/+11
| | | | | | | | | | | | | | | | | | POSIX and C++11 require that a thread can destroy a mutex if no other thread owns the mutex, is blocked on the mutex, or will try to acquire it in the future. After destroying the mutex, it can reuse or unmap the underlying memory. Thus, we must not access a mutex' memory after releasing it. Currently, we can load the private flag after releasing the mutex, which is fixed by this patch. See https://sourceware.org/bugzilla/show_bug.cgi?id=13690 for more background. We need to call futex_wake on the lock after releasing it, however. This is by design, and can lead to spurious wake-ups on unrelated futex words (e.g., when the mutex memory is reused for another mutex). This behavior is documented in the glibc-internal futex API and in recent drafts of the Linux kernel's futex documentation (see the draft_futex branch of git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git).
* Fix SYSCALL_CANCEL for empty argumetnsAdhemerval Zanella2015-12-171-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the SYSCALL_CANCEL macro for usage with zero argument number (for instance SYSCALL_CANCEL (pause)) using a similar approach used for SOCKETCALL_CANCEL. GLIBC build still does not hit this issue still since SYSCALL_CANCEL is not currently being used for zero arguments calls. Tested on i386, x86_64, powerpc64le, aarch64. * sysdeps/unix/sysdep.h (SYSCALL_CANCEL): Fix macro for zero argument syscalls. (__SYSCALL0): New macro. (__SYSCALL1): Likewise. (__SYSCALL2): Likewise. (__SYSCALL3): Likewise. (__SYSCALL4): Likewise. (__SYSCALL5): Likewise. (__SYSCALL6): Likewise. (__SYSCALL7): Likewise. (__SYSCALL_CONCAT_X): Likewise. (__SYSCALL_CONCAT): Likewise. (__SYSCALL_DIST): Likewise. (__SYSCALL_CALL): Likewise.
* Provide x32 timesH.J. Lu2015-12-171-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since times returns 64-bit clock_t on x32, we need to provide x32 times by redefining INTERNAL_SYSCALL_NCS and INTERNAL_SYSCALL_ERROR_P with 64-bit return type for syscall. All system calls returning 64-bit integer, which are lseek, time and times, must be handled specially for x32. lseek is handled by x32 lseek.S and time doesn't check syscall return. times is the only missed one. Before this patch, there are 0000000 <__times>: 0: b8 64 00 00 40 mov $0x40000064,%eax 5: 0f 05 syscall 7: 48 63 d0 movslq %eax,%rdx ^^^^^^^^^^ Incorrect signed extension a: 48 83 fa f2 cmp $0xfffffffffffffff2,%rdx e: 75 07 jne 17 <__times+0x17> 10: 3d 00 f0 ff ff cmp $0xfffff000,%eax ^^^^^^^^^^^^^^^^^^^^^ 32-bit compare 15: 77 11 ja 28 <__times+0x28> 17: 48 83 fa ff cmp $0xffffffffffffffff,%rdx 1b: b8 00 00 00 00 mov $0x0,%eax 20: 48 0f 45 c2 cmovne %rdx,%rax 24: c3 retq After this patch, there are 00000000 <__times>: 0: b8 64 00 00 40 mov $0x40000064,%eax 5: 0f 05 syscall 7: 48 83 f8 f2 cmp $0xfffffffffffffff2,%rax b: 75 08 jne 15 <__times+0x15> d: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax 13: 77 13 ja 28 <__times+0x28> 15: 48 83 f8 ff cmp $0xffffffffffffffff,%rax 19: ba 00 00 00 00 mov $0x0,%edx 1e: 48 0f 44 c2 cmove %rdx,%rax 22: c3 retq The incorrect signed extension and 32-bit compare are gone. [BZ #19363] * sysdeps/unix/sysv/linux/x86_64/x32/times.c: New file.
* Add REGISTERS_CLOBBERED_BY_SYSCALL for x86-64H.J. Lu2015-12-161-2/+5
| | | | | | | | | | | X86-64 system calls use a different calling convention, which clobbers CC, %r11 an %rcx registers. Define REGISTERS_CLOBBERED_BY_SYSCALL for x86-64 inline asm statements. * sysdeps/unix/sysv/linux/x86_64/sysdep.h (REGISTERS_CLOBBERED_BY_SYSCALL): New. (INTERNAL_SYSCALL_NCS): Use it. (INTERNAL_SYSCALL_NCS_TYPES): Likewise.
* Add Prefer_MAP_32BIT_EXEC to map executable pages with MAP_32BIT hjl/32bit/masterH.J. Lu2015-12-153-0/+121
| | | | | | | | | | | | | | | | | | | | | According to Silvermont software optimization guide, for 64-bit applications, branch prediction performance can be negatively impacted when the target of a branch is more than 4GB away from the branch. Add the Prefer_MAP_32BIT_EXEC bit so that mmap will try to map executable pages with MAP_32BIT first. NB: MAP_32BIT will map to lower 2GB, not lower 4GB, address. Prefer_MAP_32BIT_EXEC reduces bits available for address space layout randomization (ASLR), which is always disabled for SUID programs and can only be enabled by setting environment variable, LD_PREFER_MAP_32BIT_EXEC. On Fedora 23, this patch speeds up GCC 5 testsuite by 3% on Silvermont. [BZ #19367] * sysdeps/unix/sysv/linux/wordsize-64/mmap.c: New file. * sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/mmap.c: Likewise. * sysdeps/x86/cpu-features.h (bit_Prefer_MAP_32BIT_EXEC): New. (index_Prefer_MAP_32BIT_EXEC): Likewise.
* Make obsolete syscall wrappers into compat symbols (bug 18472).Joseph Myers2015-12-145-46/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various Linux kernel syscalls have become obsolete over time. Specifically, the following are obsolete in all kernel versions supported by glibc, are not present for architectures more recently added to the kernel, and as such, the wrapper functions for them should be compat symbols, not in static libc and not available for new links with shared libc. * bdflush: in Linux 2.6, does nothing if present. * create_module get_kernel_syms query_module: Linux 2.4 module interface, syscalls not present in Linux 2.6. * uselib: part of the mechanism for loading a.out shared libraries, irrelevant with ELF. This patch adds support for syscalls.list to list syscall aliases of the form NAME@VERSION:OBSOLETED, with SHLIB_COMPAT conditionals being generated for such aliases. Those five syscalls are then made into compat symbols (obsoleted in glibc 2.23, so future ports won't have these symbols at all), with the header <sys/kdaemon.h> declaring bdflush being removed. When we move to 3.2 as minimum kernel version, the same can be done for nfsservctl (removed in Linux 3.1) as well. Tested for x86_64 and x86 (testsuite, as well as checking that the symbols in question indeed become compat symbols, that they are indeed omitted from static libc, and that the generated SHLIB_COMPAT conditionals look right). [BZ #18472] * sysdeps/unix/Makefile ($(objpfx)stub-syscalls.c): Handle entries for the form NAME@VERSION:OBSOLETED and generate SHLIB_COMPAT conditionals for them. * sysdeps/unix/make-syscalls.sh (emit_weak_aliases): Likewise. * sysdeps/unix/sysv/linux/sys/kdaemon.h: Remove file. * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Remove sys/kdaemon.h. * sysdeps/unix/sysv/linux/syscalls.list (bdflush): Make into compat-only syscall, obsoleted in glibc 2.23. (create_module): Likewise. (get_kernel_syms): Likewise. (query_module): Likewise. (uselib): Likewise. * manual/sysinfo.texi (System Parameters): Do not mention bdflush.
* Cleanup ARM ioperm implementationAurelien Jarno2015-12-121-9/+2
| | | | | Since GLIBC requires a minimum 2.6.32 kernel, the patch cleanups the ARM ioperm by removing pre-2.4.23 kernel support.
* grantpt: trust the kernel about pty group and permission modeAurelien Jarno2015-12-101-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to POSIX the grantpt() function does the following: The grantpt() function shall change the mode and ownership of the slave pseudo-terminal device associated with its master pseudo-terminal counterpart. The fildes argument is a file descriptor that refers to a master pseudo-terminal device. The user ID of the slave shall be set to the real UID of the calling process and the group ID shall be set to an unspecified group ID. The permission mode of the slave pseudo-terminal shall be set to readable and writable by the owner, and writable by the group. Historically the GNU libc has been responsible to setup the permission mode to 0620 and the group to 'tty' usually number 5, using the pt_chown helper, badly known for its security issues. With the creation of the devpts filesytem in the Linux kernel, this responsibility has been moved to the Linux kernel. The system is responsible to mount the devpts filesystem in /dev/pts with the options gid=5 and mode=0620. In that case the GNU libc has nothing to do and pt_chown is not need anymore. So far so good. The problem is that by default the devpts filesystem is shared between all mounts, and that contrary to other filesystem, the mount options are honored at the second mount, including for the default mount options. Given it corresponds to mode=0600 without gid parameter (that is the filesystem GID of the creating process), it's common to see systems where the devpts filesystem is mounted using these options. It is enough to run a "mount -t devpts devpts /mychroot/dev/pts" to come into this situation, and it's unfortunately wrongly used in a lot of scripts dealing with chroots, or for creating virtual machines images. When this happens the GNU libc tries to fix the group and permission mode of the pty nodes, and given it fails to do so for non-root users, grantpt() almost always fail. It means users are not able to open new terminals. This patch changes grantpt() to not enforce this anymore, while still enforcing minimum security measures to the permission mode. Therefore the responsibility to follow POSIX is now shared at the system level, i.e. kernel + system scripts + GNU libc. It stops trying to change the group, and makes the pty node readable and writable by the owner, and writable by the group only when originally writable and when the group is the tty one. As a result, on a system wrongly mounted with gid=0 and mode=0600, the pty nodes won't be accessible by the tty group, but the grantpt() function will succeed and users will have a working system. The system is not fully POSIX compliant (which might be an admin choice to default to "mesg n" mode), but the GNU libc is not to blame here, as without the pt_chown helper it can't do anything. With this patch there should not be any reason left to build the GNU libc with the --enable-pt_chown configure option on a GNU/Linux system.