Commit Graph

11699 Commits

Author SHA1 Message Date
Andreas Schwab
c4fde9669a Don't write beyond destination in __mempcpy_avx512_no_vzeroupper (bug 23196)
When compiled as mempcpy, the return value is the end of the destination
buffer, thus it cannot be used to refer to the start of it.

(cherry picked from commit 9aaaab7c6e)
2021-08-27 16:22:13 -07:00
Stefan Liebler
b3356fb4a1 Fix blocking pthread_join. [BZ #23137]
On s390 (31bit) if glibc is build with -Os, pthread_join sometimes
blocks indefinitely. This is e.g. observable with
testcase intl/tst-gettext6.

pthread_join is calling lll_wait_tid(tid), which performs the futex-wait
syscall in a loop as long as tid != 0 (thread is alive).

On s390 (and build with -Os), tid is loaded from memory before
comparing against zero and then the tid is loaded a second time
in order to pass it to the futex-wait-syscall.
If the thread exits in between, then the futex-wait-syscall is
called with the value zero and it waits until a futex-wake occurs.
As the thread is already exited, there won't be a futex-wake.

In lll_wait_tid, the tid is stored to the local variable __tid,
which is then used as argument for the futex-wait-syscall.
But unfortunately the compiler is allowed to reload the value
from memory.

With this patch, the tid is loaded with atomic_load_acquire.
Then the compiler is not allowed to reload the value for __tid from memory.

ChangeLog:

	[BZ #23137]
	* sysdeps/nptl/lowlevellock.h (lll_wait_tid):
	Use atomic_load_acquire to load __tid.

(cherry picked from commit 1660901840)
2021-08-27 16:22:12 -07:00
Joseph Myers
1ab675ca63 Add PTRACE_SECCOMP_GET_METADATA from Linux 4.16 to sys/ptrace.h.
This patch adds the PTRACE_SECCOMP_GET_METADATA constant from Linux
4.16 to all relevant sys/ptrace.h files.  A type struct
__ptrace_seccomp_metadata, analogous to other such types, is also
added.

Tested for x86_64, and with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): New enum value and macro.
	* sysdeps/unix/sysv/linux/bits/ptrace-shared.h
	(struct __ptrace_seccomp_metadata): New type.
	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/x86/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.

(cherry picked from commit 9320ca88a1)
2021-08-27 16:22:11 -07:00
H.J. Lu
c01dc8b1ff Update RWF_SUPPORTED for Linux kernel 4.16 [BZ #22947]
Add RWF_APPEND to RWF_SUPPORTED to support Linux kernel 4.16.

	[BZ #22947]
	* bits/uio-ext.h (RWF_APPEND): New.
	* sysdeps/unix/sysv/linux/bits/uio-ext.h (RWF_APPEND): Likewise.
	* manual/llio.texi: Document RWF_APPEND.
	* misc/tst-preadvwritev2-common.c (RWF_APPEND): New.
	(RWF_SUPPORTED): Add RWF_APPEND.

(cherry picked from commit f2652643d7)
2021-08-27 16:22:10 -07:00
Jesse Hathaway
dadc309087 getlogin_r: return early when linux sentinel value is set
When there is no login uid Linux sets /proc/self/loginid to the sentinel
value of, (uid_t) -1. If this is set we can return early and avoid
needlessly looking up the sentinel value in any configured nss
databases.

Checked on aarch64-linux-gnu.

	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Return
	early when linux sentinel value is set.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit cc8a1620eb)
2021-08-27 16:22:10 -07:00
Aurelien Jarno
b88e5137e6 RISC-V: fix struct kernel_sigaction to match the kernel version [BZ #23069]
The RISC-V kernel doesn't define SA_RESTORER, hence the kernel version
of struct sigaction doesn't have the sa_restorer field. The default
kernel_sigaction.h therefore can't be used.

This patch adds a RISC-V specific version of kernel_sigaction.h to fix
the issue. This fixes for example the libnih testsuite.

Note that this patch is not needed in master as the bug has been fixed
by commit b4a5d26d88 ("linux: Consolidate sigaction implementation").
2021-08-27 16:22:08 -07:00
Florian Weimer
80153017d1 Linux i386: tst-bz21269 triggers SIGBUS on some kernels
In addition to SIGSEGV and SIGILL, SIGBUS is also a possible signal
generated by the kernel.

(cherry picked from commit 4d76d3e59d)
2021-08-27 16:22:08 -07:00
Andrew Senkevich
ee056103a0 Fix i386 memmove issue (bug 22644).
[BZ #22644]
	* sysdeps/i386/i686/multiarch/memcpy-sse2-unaligned.S: Fixed
	branch conditions.
	* string/test-memmove.c (do_test2): New testcase.

(cherry picked from commit cd66c0e584)
2021-08-27 16:22:08 -07:00
Andrew Waterman
012483cf93 RISC-V: fmax/fmin: Handle signalling NaNs correctly.
RISC-V's fmax(sNAN,4) returns 4 but glibc expects it to return qNAN.

	* sysdeps/riscv/rvd/s_fmax.c (__fmax): Handle sNaNs correctly.
	* sysdeps/riscv/rvd/s_fmin.c (__fmin): Likewise.
	* sysdeps/riscv/rvf/s_fmaxf.c (__fmaxf): Likewise.
	* sysdeps/riscv/rvf/s_fminf.c (__fminf): Likewise.

(cherry picked from commit fdcc625376)
2021-08-27 16:22:07 -07:00
DJ Delorie
ab9c196492 RISC-V: Do not initialize $gp in TLS macros.
RISC-V TLS doesn't require GP to be initialized, and doing so breaks
TLS in a shared object.

(cherry picked from commit 8090720a87)
2021-08-27 16:22:07 -07:00
Adhemerval Zanella
83d6db8187 i386: Fix i386 sigaction sa_restorer initialization (BZ#21269)
This patch fixes the i386 sa_restorer field initialization for sigaction
syscall for kernel with vDSO.  As described in bug report, i386 Linux
(and compat on x86_64) interprets SA_RESTORER clear with nonzero
sa_restorer as a request for stack switching if the SS segment is 'funny'.
This means that anything that tries to mix glibc's signal handling with
segmentation (for instance through modify_ldt syscall) is randomly broken
depending on what values lands in sa_restorer.

The testcase added  is based on Linux test tools/testing/selftests/x86/ldt_gdt.c,
more specifically in do_multicpu_tests function.  The main changes are:

  - C11 atomics instead of plain access.

  - Remove x86_64 support which simplifies the syscall handling and fallbacks.

  - Replicate only the test required to trigger the issue.

Checked on i686-linux-gnu.

	[BZ #21269]
	* sysdeps/unix/sysv/linux/i386/Makefile (tests): Add tst-bz21269.
	* sysdeps/unix/sysv/linux/i386/sigaction.c (SET_SA_RESTORER): Clear
	sa_restorer for vDSO case.
	* sysdeps/unix/sysv/linux/i386/tst-bz21269.c: New file.

(cherry picked from commit 68448be208)
2017-11-17 16:04:29 -02:00
Dmitry V. Levin
fbac9a26b2 linux/powerpc: sync sys/ptrace.h with Linux 4.15 [BZ #22433, #22807]
Tested with strace.

* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h (__ptrace_request): Add
PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS, PTRACE_SETFPREGS,
PTRACE_GETVRREGS, PTRACE_SETVRREGS, PTRACE_GETEVRREGS,
PTRACE_SETEVRREGS, PTRACE_GETREGS64, PTRACE_SETREGS64,
PTRACE_GET_DEBUGREG, PTRACE_SET_DEBUGREG, PTRACE_GETVSRREGS,
PTRACE_SETVSRREGS, and PTRACE_SINGLEBLOCK.

(cherry picked from commit f5f473a9d0)
2018-02-10 23:19:32 +00:00
Tulio Magno Quites Machado Filho
3d67bc8070 powerpc: Undefine Linux ptrace macros that conflict with __ptrace_request
Linux ptrace headers define macros whose tokens conflict with the
constants of enum __ptrace_request causing build errors when
asm/ptrace.h or linux/ptrace.h are included before sys/ptrace.h.

	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Undefine Linux
	macros used in __ptrace_request.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
(cherry picked from commit 398c6fddaf)
2018-02-26 10:40:17 -03:00
Aurelien Jarno
4d1ae634e6 sparc32: Add nop before __startcontext to stop unwinding [BZ #22919]
On sparc32 tst-makecontext fails, as backtrace called within a context
created by makecontext to yield infinite backtrace.

Fix that the same way than nios2 by adding a nop just before
__startcontext. This is needed as otherwise FDE lookup just repeatedly
finds __setcontext's FDE in an infinite loop, due to the convention of
using 'address - 1' for FDE lookup.

Changelog:
	[BZ #22919]
	* sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S (__startcontext):
	Add nop before __startcontext, add explaining comments.

(cherry picked from commit 9aa5c222b9)
2018-03-09 00:14:27 +01:00
Adhemerval Zanella
f109026488 powerpc: Fix TLE build for SPE (BZ #22926)
Some SPE opcodes clashes with some recent PowerISA opcodes and
until recently gas did not complain about it.  However binutils
recently changed it and now VLE configured gas does not support to
assembler some instruction that might class with VLE (HTM for
instance).  It also does not help that glibc build hardware lock
elision support as default (regardless of assembler support).

Although runtime will not actually enables TLE on SPE hardware
(since kernel will not advertise it), I see little advantage on
adding HTM support on SPE built glibc.  SPE uses an incompatible
ABI which does not allow share the same build with default
powerpc and HTM code slows down SPE without any benefict.

This patch fixes it by only building HTM when SPE configuration
is not used.

Checked with a powerpc-linux-gnuspe build. I also did some sniff
tests on a e500 hardware without any issue.

	[BZ #22926]
	* sysdeps/powerpc/powerpc32/sysdep.h (ABORT_TRANSACTION_IMPL): Define
	empty for __SPE__.
	* sysdeps/powerpc/sysdep.h (ABORT_TRANSACTION): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/elision-lock.c (__lll_lock_elision):
	Do not build hardware transactional code for __SPE__.
	* sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
	(__lll_trylock_elision): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
	(__lll_unlock_elision): Likewise.

Cherry-pick from e921c89e01.
2018-03-05 14:46:24 -03:00
Dmitry V. Levin
2d66557e88 linux/aarch64: sync sys/ptrace.h with Linux 4.15 [BZ #22433]
Remove compat-specific constants that were never exported by kernel
headers under these names.  Before linux commit v3.7-rc1~16^2~1 they
were exported with COMPAT_ prefix, and since that commit they are not
exported at all.

* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_request):
Remove arm-specific PTRACE_GET_THREAD_AREA, PTRACE_GETHBPREGS,
and PTRACE_SETHBPREGS.

(cherry picked from commit 2fd4bbaa14)
2017-12-29 23:19:32 +00:00
Adhemerval Zanella
002eeb4cda Update SH libm-tests-ulps
* sysdeps/sh/libm-test-ulps: Update.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-02-14 14:03:13 -02:00
DJ Delorie
6cb1736f3a [RISC-V] Fix parsing flags in ELF64 files.
When ldconfig reads Elf64 files to determine the ABI, it used the
Elf32 type, so read the wrong location, and stored the wrong ABI
type in the cache, making the cache useless.  This patch uses
an Elf64 type for Elf64 objects instead.

Note that pre-patch caches might need to be manually removed and
regenerated to get the correct ABIs stored.

	[BZ #22827]
	* sysdeps/unix/sysv/linux/riscv/readelflib.c (process_elf_file): Use
	64-bit ELF type for 64-bit ELF objects.

(cherry picked from commit 6a1ff640dc)
2018-02-09 18:37:15 -05:00
Paul Pluzhnikov
8205f0d10e For b/5836136, do dlsym(0, "_Unwind..."), i.e. ignore libgcc_s.so.1 dlopen failure. 2014-03-03 17:03:35 -08:00
Stan Shebs
349ff1d0d5 Fix GCC compilation issues in cherrypicks 2018-03-28 19:31:45 -07:00
Paul Pluzhnikov
9590be9960 For Google b/8315591, experimental implementation of dlopen_with_offset. 2014-03-10 14:02:07 -07:00
Paul Pluzhnikov
8eb1716c91 Disable static linking warning for dlopen and dlmopen, and disable linking warning for sys_errlist and sys_nerr. 2014-02-28 16:51:12 -08:00
Stan Shebs
31caad179b Add empty NSS borg and cache abi lists, to make testsuite work 2018-03-19 11:04:23 -07:00
Paul Pluzhnikov
502932b7f5 For b/4074041, add EXEC_ORIGIN support. Forward-ported from cl/56955623 and http://cl/59961863. 2014-03-08 15:12:52 -08:00
Stan Shebs
d41bed3ce0 As with gettimeofday, avoid vdso for clang-compiled time() 2018-03-13 11:37:02 -07:00
Stan Shebs
491d419cdd Forward-port addition of __google_pthread_signal_safe_key_create 2018-03-12 14:59:51 -07:00
Stan Shebs
a4c60a19bc Bypass gettimeofday ifunc if using clang 2018-03-02 08:39:57 -08:00
Stan Shebs
f0c4b81ce8 Skip a test that lld cannot handle 2018-02-27 11:17:27 -08:00
Stan Shebs
1a12397c10 Remove debugging hack 2018-02-20 09:12:01 -08:00
Stan Shebs
654fbaf1b7 Use LN_S in more places to forestall hard link creation 2018-02-14 09:44:15 -08:00
Stan Shebs
6614ff3213 Add workaround to get clang to accept avx-512 instructions 2018-02-07 12:57:16 -08:00
Stan Shebs
edeaa90058 Work around clang assembler error with bnd by itself on a line 2018-02-07 12:55:59 -08:00
Stan Shebs
18417626b7 Work around clang assembler error with movzx 2018-02-07 12:54:57 -08:00
Stan Shebs
85450bb67a Work around clang assembler bug with expressions in .if 2018-02-07 12:53:40 -08:00
Stan Shebs
bf806c9c4e Work around lack of .tfloat in clang assembler 2018-02-06 15:53:53 -08:00
Stan Shebs
6b6086fea8 Comment out debugging hack that pollutes namespace 2018-01-24 11:32:36 -08:00
Stan Shebs
34cb52c02f Do not pass unhandled flag to clang 2018-01-23 12:53:28 -08:00
Stan Shebs
dfb17f123a Add workarounds for incomplete float128 support in clang 2018-01-23 09:41:49 -08:00
Stan Shebs
becb228b43 clang requires -mno-see for 387 math 2018-01-23 09:40:20 -08:00
Stan Shebs
3f1c409c0a Work around a weird clang link failure 2018-01-23 09:37:55 -08:00
Stan Shebs
fe9f4b71d6 Make zero volatile to defeat constant-folding of 0.0/0.0 2018-01-23 08:28:31 -08:00
Stan Shebs
1f3a3e1742 Skip undefined va_arg_pack 2018-01-19 09:31:04 -08:00
Igor Gnatenko
56170e064e Linux: use reserved name __key in pkey_get [BZ #22797]
_key is not reserved name and we should avoid using that. It seems that
it was simple typo when pkey_* was implemented.

(cherry picked from commit 388ff7bd0d)
2018-02-07 13:53:10 +01:00
H.J. Lu
ce8a6550fa sparc: Check PIC instead of SHARED in start.S [BZ #22638]
Since start.o may be compiled as PIC, we should check PIC instead of
SHARED.

	[BZ #22638]
	* sysdeps/sparc/sparc32/start.S (_start): Check PIC instead of
	SHARED.
	* sysdeps/sparc/sparc64/start.S (_start): Likewise.

(cherry picked from commit 371b220f62)
2018-02-06 09:31:30 +00:00
Samuel Thibault
407552cf0b allocalim.h: use __glibc_likely instead of __builtin_expect
* sysdeps/pthread/allocalim.h (__libc_use_alloca): Use __glibc_likely
	instead of __builtin_expect.
2018-01-30 21:42:21 +01:00
Samuel Thibault
9a123ff05d hurd: include generic's hp-timing.h instead of copying it
* sysdeps/mach/hurd/hp-timing.h: include <sysdeps/generic/hp-timing.h>
instead of copying it.
2018-01-30 01:17:51 +01:00
Samuel Thibault
ef4cf463e5 hurd: Add tlsdesc.sym
* sysdeps/mach/hurd/i386/tlsdesc.sym: New file.
2018-01-30 00:52:48 +01:00
Samuel Thibault
ac56adbb0c hurd: disable hp timing
We don't have support for hp timing for now, even the i686 variant, which needs
to know the CPU speed.
Copied from sysdeps/generic/hp-timing.h

	* sysdeps/mach/hurd/hp-timing.h: New file.
2018-01-30 00:47:31 +01:00
Samuel Thibault
99dfbef48d hurd: Fix comments for FREAD and FWRITE
* bits/fcntl.h: Fix comment for FREAD and FWRITE.
	* sysdeps/mach/hurd/bits/fcntl.h: Likewise.
2018-01-29 23:00:17 +01:00
Samuel Thibault
ba729de643 allocalim.h: Fix codestyle
* sysdeps/pthread/allocalim.h (__libc_use_alloca): Commute operands of
	|| to respect codestyle.
2018-01-29 23:00:17 +01:00