aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
AgeCommit message (Collapse)AuthorFilesLines
2025-01-14affinity-inheritance: Overallocate CPU setsStefan Liebler1-3/+4
Some kernels on S390 appear to return a CPU affinity mask based on configured processors rather than the ones online. Overallocate the CPU set to match that, but operate only on the ones online. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Co-authored-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2025-01-13sh4: ensure FPSCR.PR==0 when executing FRCHG [BZ #27543]mirabilos3-0/+10
If the bit is not 0, the operations FRCHG and FSCHG are undefined and cause a trap; qemu now checks for this as well, so we set it to 0 temporarily and restore the old value in getcontext afterwards (setcontext/swapcontext already do so). From the discussion in the bugreport, this can probably be optimised in one place but none of the people involved are SH4 assembly experts, this patch is field-tested, and it’s not a code path run often. The other question, what happens if a signal occurs while the bit is temporarily 0, is also still unsolved, but to fix that a kernel change is most likely needed; this patch changes a certain trap on many CPUs for a hard-to-get trap in a signal handler if a signal is delivered during the few instructions the PR bit is temporarily set to 0, so it’s not a regression for most users. See BZ and https://bugs.launchpad.net/qemu/+bug/1796520 for related discussion, references and review comments. Signed-off-by: mirabilos <tg@debian.org> Reviewed-by: Oleg Endo <olegendo@gcc.gnu.org> Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-01-13aarch64: Use 64-bit variable to access the special registersAdhemerval Zanella2-2/+2
clang issues: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths] while tryng to use 32 bit variables with 'mrs' to get/set the fpsr, dczid_el0, and ctr.
2025-01-10Linux: Update internal copy of '<sys/rseq.h>'Michael Jeanson1-0/+11
Sync the internal copy of '<sys/rseq.h>' with the latest Linux kernel 'include/uapi/linux/rseq.h'. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-10nptl: Move the rseq area to the 'extra TLS' blockMichael Jeanson10-48/+205
Move the rseq area to the newly added 'extra TLS' block, this is the last step in adding support for the rseq extended ABI. The size of the rseq area is now dynamic and depends on the rseq features reported by the kernel through the elf auxiliary vector. This will allow applications to use rseq features past the 32 bytes of the original rseq ABI as they become available in future kernels. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-10nptl: Introduce <rseq-access.h> for RSEQ_* accessorsMichael Jeanson1-0/+8
In preparation to move the rseq area to the 'extra TLS' block, we need accessors based on the thread pointer and the rseq offset. The ONCE variant of the accessors ensures single-copy atomicity for loads and stores which is required for all fields once the registration is active. A separate header is required to allow including <atomic.h> which results in an include loop when added to <tcb-access.h>. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-10nptl: add rtld_hidden_proto to __rseq_size and __rseq_offsetMichael Jeanson2-15/+28
This allows accessing the internal aliases of __rseq_size and __rseq_offset from ld.so without ifdefs and avoids dynamic symbol binding at run time for both variables. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-10Add Linux 'extra TLS'Michael Jeanson1-0/+71
Add the Linux implementation of 'extra TLS' which will allocate space for the rseq area at the end of the TLS blocks in allocation order. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-10nptl: Add rseq auxvalsMichael Jeanson4-5/+39
Get the rseq feature size and alignment requirement from the auxiliary vector for use inside the dynamic loader. Use '__rseq_size' directly to store the feature size. If the main thread registration fails or is disabled by tunable, reset the value to 0. This will be used in the TLS block allocator to compute the size and alignment of the rseq area block for the extended ABI support. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-09tests: Verify inheritance of cpu affinitySiddhesh Poyarekar2-0/+72
Add a couple of tests to verify that CPU affinity set using sched_setaffinity and pthread_setaffinity_np are inherited by a child process and child thread. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-01-08Revert "configure: default to --prefix=/usr on GNU/Linux"DJ Delorie2-7/+2
This reverts commit 81439a116cf48583127ddf1f09809440aa40969a.
2025-01-07elf: Second ld.so relocation only if libc.so has been loadedFlorian Weimer3-0/+36
Commit 8f8dd904c4a2207699bb666f30acceb5209c8d3f (“elf: rtld_multiple_ref is always true”) removed some code that happened to enable compatibility with programs that do not link against libc.so. Such programs cannot call dlopen or any dynamic linker functions (except __tls_get_addr), so this is not really useful. Still ld.so should not crash with a null-pointer dereference or undefined symbol reference in these cases. In the main relocation loop, call _dl_relocate_object unconditionally because it already checks if the object has been relocated. If libc.so was loaded, self-relocate ld.so against it and call __rtld_mutex_init and __rtld_malloc_init_real to activate the full implementations. Those are available only if libc.so is there, so skip these initialization steps if libc.so is absent. Without libc.so, the global scope can be completely empty. This can cause ld.so self-relocation to fail because if it uses symbol-based relocations, which is why the second ld.so self-relocation is not performed if libc.so is missing. The previous concern regarding GOT updates through self-relocation no longer applies because function pointers are updated explicitly through __rtld_mutex_init and __rtld_malloc_init_real, and not through relocation. However, the second ld.so self-relocation is still delayed, in case there are other symbols being used. Fixes commit 8f8dd904c4a2207699bb666f30acceb5209c8d3f (“elf: rtld_multiple_ref is always true”). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-01-03AArch64: Add vector tanpi routinesJoe Ramsay1-0/+5
Vector variant of the new C23 tanpi. New tests pass on AArch64.
2025-01-03AArch64: Add vector cospi routinesJoe Ramsay1-0/+5
Vector variant of the new C23 cospi. New tests pass on AArch64.
2025-01-03AArch64: Add vector sinpi to libmvecJoe Ramsay1-0/+5
Vector variant of the new C23 sinpi. New tests pass on AArch64.
2025-01-04Rename have-mtls-descriptor to have-test-mtls-descriptorH.J. Lu1-1/+1
Since have-mtls-descriptor is only used for glibc testing, rename it to have-test-mtls-descriptor. Also enable tst-gnu2-tls2-amx only if $(have-test-mtls-descriptor) == gnu2. Tested with GCC 14 and Clang 19/18/17 on x86-64. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2025-01-03not-cancel.h: Support testing fortify build with ClangH.J. Lu1-5/+5
When Clang is used to test fortify glibc build configured with --enable-fortify-source=N clang issues errors like In file included from tst-rfc3484.c:60: In file included from ./getaddrinfo.c:81: ../sysdeps/unix/sysv/linux/not-cancel.h:36:10: error: reference to overloaded function could not be resolved; did you mean to call it? 36 | __typeof (open64) __open64_nocancel; | ^~~~~~~~ ../include/bits/../../io/bits/fcntl2.h:127:1: note: possible target for call 127 | open64 (__fortify_clang_overload_arg (const char *, ,__path), int __oflag, | ^ ../include/bits/../../io/bits/fcntl2.h:118:1: note: possible target for call 118 | open64 (__fortify_clang_overload_arg (const char *, ,__path), int __oflag) | ^ ../include/bits/../../io/bits/fcntl2.h:114:1: note: possible target for call 114 | open64 (const char *__path, int __oflag, mode_t __mode, ...) | ^ ../io/fcntl.h:219:12: note: possible target for call 219 | extern int open64 (const char *__file, int __oflag, ...) __nonnull ((1)); | ^ because clang fortify support for functions with variable arguments relies on function overload. Update not-cancel.h to avoid __typeof on functions with variable arguments. Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2025-01-02mlock, mlock2, munlock: Use __attr_access_none macroSam James1-1/+1
This fixes build failures using GCC 7.5.0 against glibc headers, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118194#c5. Followup to 013106ae677af9836614ace1a01d25b63fa555a7. Reported-by: vvinayag@arm.com
2025-01-01Update copyright in generated files by running "make"Paul Eggert1-0/+0
2025-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert1620-1620/+1620
2025-01-01mlock, mlock2, munlock: Tell the compiler we don't dereference the pointerXi Ruoyao1-1/+2
Since https://gcc.gnu.org/r11-959, the compiler emits -Wmaybe-uninitialized if a const pointer to an uninitialized buffer is passed. Tell the compiler we don't dereference the pointer to remove the false alarm. Link: https://gcc.gnu.org/PR118194 Signed-off-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-31elf: Do not change stack permission on dlopen/dlmopenAdhemerval Zanella3-68/+9
If some shared library loaded with dlopen/dlmopen requires an executable stack, either implicitly because of a missing GNU_STACK ELF header (where the ABI default flags implies in the executable bit) or explicitly because of the executable bit from GNU_STACK; the loader will try to set the both the main thread and all thread stacks (from the pthread cache) as executable. Besides the issue where any __nptl_change_stack_perm failure does not undo the previous executable transition (meaning that if the library fails to load, there can be thread stacks with executable stacks), this behavior was used on a CVE [1] as a vector for RCE. This patch changes that if a shared library requires an executable stack, and the current stack is not executable, dlopen fails. The change is done only for dynamically loaded modules, if the program or any dependency requires an executable stack, the loader will still change the main thread before program execution and any thread created with default stack configuration. [1] https://www.qualys.com/2023/07/19/cve-2023-38408/rce-openssh-forwarded-ssh-agent.txt Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2024-12-30x86-64: Reorder dynamic linker list in ldd script (bug 32508)Florian Weimer1-1/+1
Move the x86-64 loader first, before the i386 and x32 loaders. In most cases, it's the loader the script needs. This avoids an error message if the i386 loader does not work. The effect of this change to the generated ldd script looks like this: -RTLDLIST="/lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2 /libx32/ld-linux-x32.so.2" +RTLDLIST="/lib64/ld-linux-x86-64.so.2 /lib/ld-linux.so.2 /libx32/ld-linux-x32.so.2" Reviewed-by: Sam James <sam@gentoo.org>
2024-12-23include/sys/cdefs.h: Add __attribute_optimization_barrier__Adhemerval Zanella4-4/+4
Add __attribute_optimization_barrier__ to disable inlining and cloning on a function. For Clang, expand it to __attribute__ ((optnone)) Otherwise, expand it to __attribute__ ((noinline, clone)) Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-22hppa: Simplify handling of sanity check errors in clone.S.John David Anglin1-6/+5
This simplifies the handling of sanity check errors in clone.S. Adjusted a couple of comments to reflect current code. Signed-off-by: John David Anglin <dave.anglin@bell.net>
2024-12-22hppa: add cacheflush() syscall wrapperJohn David Anglin5-0/+46
The hppa Linux kernel supports the cacheflush() syscall since version 6.5. This adds the glibc syscall wrapper. Signed-off-by: Helge Deller <deller@gmx.de> --- v2: This patch was too late in release cycle for GLIBC_2.40, so update now to GLIBC_2.41 instead.
2024-12-22dirent: Remove variable length array structure for tst-getdents64.cAdhemerval Zanella1-11/+7
Clang emits the following warnings: ../sysdeps/unix/sysv/linux/tst-getdents64.c:111:18: error: fields must have a constant size: 'variable length array in structure' extension will never be supported char buffer[buffer_size]; ^ Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-20Add F_CREATED_QUERY from Linux 6.12 to bits/fcntl-linux.hJoseph Myers1-0/+1
Linux 6.12 adds a new constant F_CREATED_QUERY. Add it to glibc's bits/fcntl-linux.h. Tested for x86_64.
2024-12-20Add HWCAP_LOONGARCH_LSPW from Linux 6.12 to bits/hwcap.hJoseph Myers1-0/+1
Add the new Linux 6.12 HWCAP_LOONGARCH_LSPW to the corresponding bits/hwcap.h. Tested with build-many-glibcs.py for loongarch64-linux-gnu-lp64d.
2024-12-20Add MSG_SOCK_DEVMEM from Linux 6.12 to bits/socket.hJoseph Myers1-0/+2
Linux 6.12 adds a constant MSG_SOCK_DEVMEM (recall that various constants such as this one are defined in the non-uapi linux/socket.h but still form part of the kernel/userspace interface, so that non-uapi header is one that needs checking each release for new such constants). Add it to glibc's bits/socket.h. Tested for x86_64.
2024-12-19Linux: Accept null arguments for utimensat pathnameFlorian Weimer1-3/+0
This matches kernel behavior. With this change, it is possible to use utimensat as a replacement for the futimens interface, similar to what glibc does internally. Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
2024-12-19Add SCHED_EXT from Linux 6.12 to bits/sched.hJoseph Myers2-1/+2
Linux 6.12 adds the SCHED_EXT constant. Add it to glibc's bits/sched.h and update the kernel version in tst-sched-consts.py. Tested for x86_64.
2024-12-19hppa: Fix strace detach-vfork testJohn David Anglin2-47/+64
This change implements vfork.S for direct support of the vfork syscall. clone.S is revised to correct child support for the vfork case. The main bug was creating a frame prior to the clone syscall. This was done to allow the rp and r4 registers to be saved and restored from the stack frame. r4 was used to save and restore the PIC register, r19, across the system call and the call to set errno. But in the vfork case, it is undefined behavior for the child to return from the function in which vfork was called. It is surprising that this usually worked. Syscalls on hppa save and restore rp and r19, so we don't need to create a frame prior to the clone syscall. We only need a frame when __syscall_error is called. We also don't need to save and restore r19 around the call to $$dyncall as r19 is not used in the code after $$dyncall. This considerably simplifies clone.S. Signed-off-by: John David Anglin <dave.anglin@bell.net>
2024-12-19Update kernel version to 6.12 in header constant testsJoseph Myers3-4/+4
There are no new constants covered by tst-mman-consts.py, tst-mount-consts.py or tst-pidfd-consts.py in Linux 6.12 that need any header changes, so update the kernel version in those tests. (tst-sched-consts.py will need updating separately along with adding SCHED_EXT.) Tested with build-many-glibcs.py.
2024-12-18Update syscall lists for Linux 6.12Joseph Myers1-2/+2
Linux 6.12 has no new syscalls. Update the version number in syscall-names.list to reflect that it is still current for 6.12. Tested with build-many-glibcs.py.
2024-12-18sys/platform/x86.h: Do not depend on _Bool definition in C++ modeH.J. Lu1-1/+1
Clang does not define _Bool for -std=c++98: /usr/include/bits/platform/features.h:31:19: error: unknown type name '_Bool' 31 | static __inline__ _Bool | ^ Change _Bool to bool to silence clang++ error. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2024-12-18tst-clone3[-internal].c: Add _Atomic to silence ClangH.J. Lu2-4/+4
Add _Atomic to futex_wait argument and ctid in tst-clone3[-internal].c to silence Clang error: ../sysdeps/unix/sysv/linux/tst-clone3-internal.c:93:3: error: address argument to atomic operation must be a pointer to _Atomic type ('pid_t *' (aka 'int *') invalid) 93 | wait_tid (&ctid, CTID_INIT_VAL); | ^ ~~~~~ ../sysdeps/unix/sysv/linux/tst-clone3-internal.c:51:21: note: expanded from macro 'wait_tid' 51 | while ((__tid = atomic_load_explicit (ctid_ptr, \ | ^ ~~~~~~~~ /usr/bin/../lib/clang/19/include/stdatomic.h:145:30: note: expanded from macro 'atomic_load_explicit' 145 | #define atomic_load_explicit __c11_atomic_load | ^ Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-16Use empty initializer to silence GCC 4.9 or olderH.J. Lu2-4/+4
Use empty initializer to silence GCC 4.9 or older: getaddrinfo.c: In function ‘gaih_inet’: getaddrinfo.c:1135:24: error: missing braces around initializer [-Werror=missing-braces] / sizeof (struct gaih_typeproto)] = {0}; ^ Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-15Linux: Check for 0 return value from vDSO getrandom probeFlorian Weimer1-1/+1
As of Linux 6.13, there is no code in the vDSO that declines this initialization request with the special ~0UL state size. If the vDSO has the function, the call succeeds and returns 0. It's expected that the code would follow the “a negative value indicating an error” convention, as indicated in the __cvdso_getrandom_data function comment, so that INTERNAL_SYSCALL_ERROR_P on glibc's side would return true. This commit changes the commit to check for zero to indicate success instead, which covers potential future non-zero success return values and error returns. Fixes commit 4f5704ea347e52ac3f272d1341da10aed6e9973e ("powerpc: Use correct procedure call standard for getrandom vDSO call (bug 32440)").
2024-12-15Revert "Add braces in initializers for GCC 4.9 or older"H.J. Lu2-4/+4
This reverts commit 8aa2a9e0339215012354f3c4a262edda838134e8. as not all targets need braces.
2024-12-15Return EXIT_UNSUPPORTED if __builtin_add_overflow unavailableH.J. Lu1-0/+7
Since GCC 4.9 doesn't have __builtin_add_overflow: In file included from tst-stringtable.c:180:0: stringtable.c: In function ‘stringtable_finalize’: stringtable.c:185:7: error: implicit declaration of function ‘__builtin_add_overflow’ [-Werror=implicit-function-declaration] else if (__builtin_add_overflow (previous->offset, ^ return EXIT_UNSUPPORTED for GCC 4.9 or older. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-14Add braces in initializers for GCC 4.9 or olderH.J. Lu2-4/+4
Add braces to silence GCC 4.9 or older: getaddrinfo.c: In function ‘gaih_inet’: getaddrinfo.c:1135:24: error: missing braces around initializer [-Werror=missing-braces] / sizeof (struct gaih_typeproto)] = {0}; ^ Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-12Implement C23 atan2piJoseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the atan2pi functions (atan2(y,x)/pi). Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-11Implement C23 atanpiJoseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the atanpi functions (atan(x)/pi). Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-11powerpc: Use correct procedure call standard for getrandom vDSO call (bug 32440)Florian Weimer1-6/+11
A plain indirect function call does not work on POWER because success and failure are signaled through a flag register, and not via the usual Linux negative return value convention. This has potential security impact, in two ways: the return value could be out of bounds (EAGAIN is 11 on powerpc6le), and no random bytes have been written despite the non-error return value. Fixes commit 461cab1de747f3842f27a5d24977d78d561d45f9 ("linux: Add support for getrandom vDSO"). Reported-by: Ján Stanček <jstancek@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-12-10Implement C23 asinpiJoseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the asinpi functions (asin(x)/pi). Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-09Implement C23 acospiJoseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the acospi functions (acos(x)/pi). Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-09powerpc64le: ROP changes for the *context and setjmp functionsSachin Monga4-12/+54
Add ROP protection for the getcontext, setcontext, makecontext, swapcontext and __sigsetjmp_symbol functions. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2024-12-09nptl: add RSEQ_SIG for RISC-VMichael Jeanson1-0/+44
Enable RSEQ for RISC-V, support was added in Linux 5.18. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
2024-12-05Implement C23 tanpiJoseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the tanpi functions (tan(pi*x)). Tested for x86_64 and x86, and with build-many-glibcs.py.