about summary refs log tree commit diff
path: root/sysdeps/unix
Commit message (Collapse)AuthorAgeFilesLines
* sparc: Fix restartable syscalls (BZ 32173) HEAD masterAdhemerval Zanella11 hours7-36/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit 'sparc: Use Linux kABI for syscall return' (86c5d2cf0ce046279baddc7faa27da71f1a89fde) did not take into account a subtle sparc syscall kABI constraint. For syscalls that might block indefinitely, on an interrupt (like SIGCONT) the kernel will set the instruction pointer to just before the syscall: arch/sparc/kernel/signal_64.c 476 static void do_signal(struct pt_regs *regs, unsigned long orig_i0) 477 { [...] 525 if (restart_syscall) { 526 switch (regs->u_regs[UREG_I0]) { 527 case ERESTARTNOHAND: 528 case ERESTARTSYS: 529 case ERESTARTNOINTR: 530 /* replay the system call when we are done */ 531 regs->u_regs[UREG_I0] = orig_i0; 532 regs->tpc -= 4; 533 regs->tnpc -= 4; 534 pt_regs_clear_syscall(regs); 535 fallthrough; 536 case ERESTART_RESTARTBLOCK: 537 regs->u_regs[UREG_G1] = __NR_restart_syscall; 538 regs->tpc -= 4; 539 regs->tnpc -= 4; 540 pt_regs_clear_syscall(regs); 541 } However, on a SIGCONT it seems that 'g1' register is being clobbered after the syscall returns. Before 86c5d2cf0ce046279, the 'g1' was always placed jus before the 'ta' instruction which then reloads the syscall number and restarts the syscall. On master, where 'g1' might be placed before 'ta': $ cat test.c #include <unistd.h> int main () { pause (); } $ gcc test.c -o test $ strace -f ./t [...] ppoll(NULL, 0, NULL, NULL, 0 On another terminal $ kill -STOP 2262828 $ strace -f ./t [...] --- SIGSTOP {si_signo=SIGSTOP, si_code=SI_USER, si_pid=2521813, si_uid=8289} --- --- stopped by SIGSTOP --- And then $ kill -CONT 2262828 Results in: --- SIGCONT {si_signo=SIGCONT, si_code=SI_USER, si_pid=2521813, si_uid=8289} --- restart_syscall(<... resuming interrupted ppoll ...>) = -1 EINTR (Interrupted system call) Where the expected behaviour would be: $ strace -f ./t [...] ppoll(NULL, 0, NULL, NULL, 0) = ? ERESTARTNOHAND (To be restarted if no handler) --- SIGSTOP {si_signo=SIGSTOP, si_code=SI_USER, si_pid=2521813, si_uid=8289} --- --- stopped by SIGSTOP --- --- SIGCONT {si_signo=SIGCONT, si_code=SI_USER, si_pid=2521813, si_uid=8289} --- ppoll(NULL, 0, NULL, NULL, 0 Just moving the 'g1' setting near the syscall asm is not suffice, the compiler might optimize it away (as I saw on cancellation.c by trying this fix). Instead, I have change the inline asm to put the 'g1' setup in ithe asm block. This would require to change the asm constraint for INTERNAL_SYSCALL_NCS, since the syscall number is not constant. Checked on sparc64-linux-gnu. Reported-by: René Rebe <rene@exactcode.de> Tested-by: Sam James <sam@gentoo.org> Reviewed-by: Sam James <sam@gentoo.org>
* LoongArch: Regenerate loongarch/arch-syscall.h by build-many-glibcs.py ↵caiyinyu5 days1-2/+0
| | | | update-syscalls.
* misc: Add support for Linux uio.h RWF_ATOMIC flagAdhemerval Zanella7 days1-0/+2
| | | | | | | | | Linux 6.11 adds the new flag for pwritev2 (commit c34fc6f26ab86d03a2d47446f42b6cd492dfdc56). Checked on x86_64-linux-gnu on 6.11 kernel. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* Update kernel version to 6.11 in header constant testsAdhemerval Zanella7 days2-2/+2
| | | | | | | | | | | This patch updates the kernel version in the tests tst-mount-consts.py, and tst-sched-consts.py to 6.11. There are no new constants covered by these tests in 6.11. Tested with build-many-glibcs.py. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* linux: Add MAP_DROPPABLE from Linux 6.11Adhemerval Zanella7 days2-1/+2
| | | | | | | | | | | | This request the page to be never written out to swap, it will be zeroed under memory pressure (so kernel can just drop the page), it is inherited by fork, it is not counted against @code{mlock} budget, and if there is no enough memory to service a page faults there is no fatal error (so not signal is sent). Tested with build-many-glibcs.py. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* Update PIDFD_* constants for Linux 6.11Adhemerval Zanella7 days2-1/+15
| | | | | | | | | | Linux 6.11 adds some more PIDFD_* constants for 'pidfs: allow retrieval of namespace file descriptors' (5b08bd408534bfb3a7cf5778da5b27d4e4fffe12). Tested with build-many-glibcs.py. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* Update syscall lists for Linux 6.11Adhemerval Zanella7 days5-2/+8
| | | | | | | | | | | | | | | | | Linux 6.11 changes for syscall are: * fstat/newfstatat for loongarch (it should be safe to add since 255dc1e4ed8 that undefine them). * clone3 for nios2, which only adds the entry point but defined __ARCH_BROKEN_SYS_CLONE3 (the syscall will always return ENOSYS). * uretprobe for x86_64 and x32. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* stdlib: Make abort/_Exit AS-safe (BZ 26275)Adhemerval Zanella8 days3-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The recursive lock used on abort does not synchronize with a new process creation (either by fork-like interfaces or posix_spawn ones), nor it is reinitialized after fork(). Also, the SIGABRT unblock before raise() shows another race condition, where a fork or posix_spawn() call by another thread, just after the recursive lock release and before the SIGABRT signal, might create programs with a non-expected signal mask. With the default option (without POSIX_SPAWN_SETSIGDEF), the process can see SIG_DFL for SIGABRT, where it should be SIG_IGN. To fix the AS-safe, raise() does not change the process signal mask, and an AS-safe lock is used if a SIGABRT is installed or the process is blocked or ignored. With the signal mask change removal, there is no need to use a recursive loc. The lock is also taken on both _Fork() and posix_spawn(), to avoid the spawn process to see the abort handler as SIG_DFL. A read-write lock is used to avoid serialize _Fork and posix_spawn execution. Both sigaction (SIGABRT) and abort() requires to lock as writer (since both change the disposition). The fallback is also simplified: there is no need to use a loop of ABORT_INSTRUCTION after _exit() (if the syscall does not terminate the process, the system is broken). The proposed fix changes how setjmp works on a SIGABRT handler, where glibc does not save the signal mask. So usage like the below will now always abort. static volatile int chk_fail_ok; static jmp_buf chk_fail_buf; static void handler (int sig) { if (chk_fail_ok) { chk_fail_ok = 0; longjmp (chk_fail_buf, 1); } else _exit (127); } [...] signal (SIGABRT, handler); [....] chk_fail_ok = 1; if (! setjmp (chk_fail_buf)) { // Something that can calls abort, like a failed fortify function. chk_fail_ok = 0; printf ("FAIL\n"); } Such cases will need to use sigsetjmp instead. The _dl_start_profile calls sigaction through _profil, and to avoid pulling abort() on loader the call is replaced with __libc_sigaction. Checked on x86_64-linux-gnu and aarch64-linux-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
* linux: Use GLRO(dl_vdso_time) on timeAdhemerval Zanella9 days1-4/+3
| | | | | | | | | | The BZ#24967 fix (1bdda52fe92fd01b424c) missed the time for architectures that define USE_IFUNC_TIME. Although it is not an issue, since there is no pointer mangling, there is also no need to call dl_vdso_vsym since the vDSO setup was already done by the loader. Checked on x86_64-linux-gnu and i686-linux-gnu.
* linux: Use GLRO(dl_vdso_gettimeofday) on gettimeofdayAdhemerval Zanella9 days1-4/+4
| | | | | | | | | | The BZ#24967 fix (1bdda52fe92fd01b424c) missed the gettimeofday for architectures that define USE_IFUNC_GETTIMEOFDAY. Although it is not an issue, since there is no pointer mangling, there is also no need to call dl_vdso_vsym since the vDSO setup was already done by the loader. Checked on x86_64-linux-gnu and i686-linux-gnu.
* linux: sparc: Fix clone for LEON/sparcv8 (BZ 31394)Adhemerval Zanella2024-10-011-0/+4
| | | | | | | | | | | | The sparc clone mitigation (faeaa3bc9f76030) added the use of flushw, which is not support by LEON/sparcv8. As discussed on the libc-alpha, 'ta 3' is a working alternative [1]. [1] https://sourceware.org/pipermail/libc-alpha/2024-August/158905.html Checked with a build for sparcv8-linux-gnu targetting leon. Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
* linux: sparc: Fix syscall_cancel for LEONAdhemerval Zanella2024-10-011-0/+9
| | | | | | | | | | LEON2/LEON3 are both sparcv8, which does not support branch hints (bne,pn) nor the return instruction. Checked with a build for sparcv8-linux-gnu targetting leon. I also checked some cancellation tests with qemu-system (targeting LEON3). Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
* arc: Cleanup arcbePavel Kozlov2024-09-251-9/+0
| | | | | | | Remove the mention of arcbe ABI to avoid any mislead. ARC big endian ABI is no longer supported. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* arc: Remove HAVE_ARC_BE macro and disable big-endian portFlorian Weimer2024-09-251-4/+0
| | | | It is no longer needed, now that ARC is always little endian.
* LoongArch: Undef __NR_fstat and __NR_newfstatat.caiyinyu2024-09-251-0/+21
| | | | | | | | | | | In Linux 6.11, fstat and newfstatat are added back. To avoid the messy usage of the fstat, newfstatat, and statx system calls, we will continue using statx only in glibc, maintaining consistency with previous versions of the LoongArch-specific glibc implementation. Signed-off-by: caiyinyu <caiyinyu@loongson.cn> Reviewed-by: Xi Ruoyao <xry111@xry111.site> Suggested-by: Florian Weimer <fweimer@redhat.com>
* misc: Enable internal use of memory protection keysFlorian Weimer2024-09-249-9/+43
| | | | This adds the necessary hidden prototypes.
* Linux: readdir64_r should not skip d_ino == 0 entries (bug 32126)Florian Weimer2024-09-211-17/+12
| | | | | | | This is the same bug as bug 12165, but for readdir_r. The regression test covers both bug 12165 and bug 32126. Reviewed-by: DJ Delorie <dj@redhat.com>
* Linux: Use readdir64_r for compat __old_readdir64_r (bug 32128)Florian Weimer2024-09-214-216/+71
| | | | | | | | | | | It is not necessary to do the conversion at the getdents64 layer for readdir64_r. Doing it piecewise for readdir64 is slightly simpler and allows deleting __old_getdents64. This fixes bug 32128 because readdir64_r handles the length check correctly. Reviewed-by: DJ Delorie <dj@redhat.com>
* AArch64: Add vector logp1 alias for log1pJoe Ramsay2024-09-191-0/+5
| | | | | | | | This enables vectorisation of C23 logp1, which is an alias for log1p. There are no new tests or ulp entries because the new symbols are simply aliases. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* Linux: Add missing scheduler constants to <sched.h>Florian Weimer2024-09-114-0/+82
| | | | | | | And add a test, misc/tst-sched-consts, that checks consistency with <sched.h>. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Add the sched_setattr and sched_getattr functionsFlorian Weimer2024-09-1139-2/+273
| | | | | | | | | | | | | | | | | | | | And struct sched_attr. In sysdeps/unix/sysv/linux/bits/sched.h, the hack that defines sched_param around the inclusion of <linux/sched/types.h> is quite ugly, but the definition of struct sched_param has already been dropped by the kernel, so there is nothing else we can do and maintain compatibility of <sched.h> with a wide range of kernel header versions. (An alternative would involve introducing a separate header for this functionality, but this seems unnecessary.) The existing sched_* functions that change scheduler parameters are already incompatible with PTHREAD_PRIO_PROTECT mutexes, so there is no harm in adding more functionality in this area. The documentation mostly defers to the Linux manual pages. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Linux: readdir_r needs to report getdents failures (bug 32124)Florian Weimer2024-09-051-1/+10
| | | | | | | | Upon error, return the errno value set by the __getdents call in __readdir_unlocked. Previously, kernel-reported errors were ignored. Reviewed-by: DJ Delorie <dj@redhat.com>
* linux: mips: Fix syscall_cancell build for __mips_isa_rev >= 6Adhemerval Zanella2024-09-021-0/+4
| | | | | | | Use beqzc instead of bnel. Checked with a mipsisa64r6el-n64-linux-gnu build and some nptl cancellation tests on qemu.
* nptl: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2024-08-2331-82/+2160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current racy approach is to enable asynchronous cancellation before making the syscall and restore the previous cancellation type once the syscall returns, and check if cancellation has happen during the cancellation entrypoint. As described in BZ#12683, this approach shows 2 problems: 1. Cancellation can act after the syscall has returned from the kernel, but before userspace saves the return value. It might result in a resource leak if the syscall allocated a resource or a side effect (partial read/write), and there is no way to program handle it with cancellation handlers. 2. If a signal is handled while the thread is blocked at a cancellable syscall, the entire signal handler runs with asynchronous cancellation enabled. This can lead to issues if the signal handler call functions which are async-signal-safe but not async-cancel-safe. For the cancellation to work correctly, there are 5 points at which the cancellation signal could arrive: [ ... )[ ... )[ syscall ]( ... 1 2 3 4 5 1. Before initial testcancel, e.g. [*... testcancel) 2. Between testcancel and syscall start, e.g. [testcancel...syscall start) 3. While syscall is blocked and no side effects have yet taken place, e.g. [ syscall ] 4. Same as 3 but with side-effects having occurred (e.g. a partial read or write). 5. After syscall end e.g. (syscall end...*] And libc wants to act on cancellation in cases 1, 2, and 3 but not in cases 4 or 5. For the 4 and 5 cases, the cancellation will eventually happen in the next cancellable entrypoint without any further external event. The proposed solution for each case is: 1. Do a conditional branch based on whether the thread has received a cancellation request; 2. It can be caught by the signal handler determining that the saved program counter (from the ucontext_t) is in some address range beginning just before the "testcancel" and ending with the syscall instruction. 3. SIGCANCEL can be caught by the signal handler and determine that the saved program counter (from the ucontext_t) is in the address range beginning just before "testcancel" and ending with the first uninterruptable (via a signal) syscall instruction that enters the kernel. 4. In this case, except for certain syscalls that ALWAYS fail with EINTR even for non-interrupting signals, the kernel will reset the program counter to point at the syscall instruction during signal handling, so that the syscall is restarted when the signal handler returns. So, from the signal handler's standpoint, this looks the same as case 2, and thus it's taken care of. 5. For syscalls with side-effects, the kernel cannot restart the syscall; when it's interrupted by a signal, the kernel must cause the syscall to return with whatever partial result is obtained (e.g. partial read or write). 6. The saved program counter points just after the syscall instruction, so the signal handler won't act on cancellation. This is similar to 4. since the program counter is past the syscall instruction. So The proposed fixes are: 1. Remove the enable_asynccancel/disable_asynccancel function usage in cancellable syscall definition and instead make them call a common symbol that will check if cancellation is enabled (__syscall_cancel at nptl/cancellation.c), call the arch-specific cancellable entry-point (__syscall_cancel_arch), and cancel the thread when required. 2. Provide an arch-specific generic system call wrapper function that contains global markers. These markers will be used in SIGCANCEL signal handler to check if the interruption has been called in a valid syscall and if the syscalls has side-effects. A reference implementation sysdeps/unix/sysv/linux/syscall_cancel.c is provided. However, the markers may not be set on correct expected places depending on how INTERNAL_SYSCALL_NCS is implemented by the architecture. It is expected that all architectures add an arch-specific implementation. 3. Rewrite SIGCANCEL asynchronous handler to check for both canceling type and if current IP from signal handler falls between the global markers and act accordingly. 4. Adjust libc code to replace LIBC_CANCEL_ASYNC/LIBC_CANCEL_RESET to use the appropriate cancelable syscalls. 5. Adjust 'lowlevellock-futex.h' arch-specific implementations to provide cancelable futex calls. Some architectures require specific support on syscall handling: * On i386 the syscall cancel bridge needs to use the old int80 instruction because the optimized vDSO symbol the resulting PC value for an interrupted syscall points to an address outside the expected markers in __syscall_cancel_arch. It has been discussed in LKML [1] on how kernel could help userland to accomplish it, but afaik discussion has stalled. Also, sysenter should not be used directly by libc since its calling convention is set by the kernel depending of the underlying x86 chip (check kernel commit 30bfa7b3488bfb1bb75c9f50a5fcac1832970c60). * mips o32 is the only kABI that requires 7 argument syscall, and to avoid add a requirement on all architectures to support it, mips support is added with extra internal defines. Checked on aarch64-linux-gnu, arm-linux-gnueabihf, powerpc-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, i686-linux-gnu, and x86_64-linux-gnu. [1] https://lkml.org/lkml/2016/3/8/1105 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Fix extraneous testing run by tst-rseq-nptl in the test driverMaciej W. Rozycki2024-08-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix an issue with commit 8f4632deb354 ("Linux: rseq registration tests") and prevent testing from being run in the process of the test driver itself rather than just the test child where one has been forked. The problem here is the unguarded use of a destructor to call a part of the testing. The destructor function, 'do_rseq_destructor_test' is called implicitly at program completion, however because it is associated with the executable itself rather than an individual process, it is called both in the test child *and* in the test driver itself. Prevent this from happening by providing a guard variable that only enables test invocation from 'do_rseq_destructor_test' in the process that has first run 'do_test'. Consequently extra testing is invoked from 'do_rseq_destructor_test' only once and in the correct process, regardless of the use or the lack of of the '--direct' option. Where called in the controlling test driver process that has neved called 'do_test' the destructor function silently returns right away without taking any further actions, letting the test driver fail gracefully where applicable. This arrangement prevents 'tst-rseq-nptl' from ever causing testing to hang forever and never complete, such as currently happening with the 'mips-linux-gnu' (o32 ABI) target. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Report error if setaffinity wrapper fails (Bug 32040)Carlos O'Donell2024-08-151-1/+1
| | | | | | | | | | | | Previously if the setaffinity wrapper failed the rest of the subtest would not execute and the current subtest would be reported as passing. Now if the setaffinity wrapper fails the subtest is correctly reported as faling. Tested manually by changing the conditions of the affinity call including setting size to zero, or checking the wrong condition. No regressions on x86_64. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Add mremap testsH.J. Lu2024-08-013-0/+94
| | | | | | | | Add tests for MREMAP_MAYMOVE and MREMAP_FIXED. On Linux, also test MREMAP_DONTUNMAP. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* linux: Update the mremap C implementation [BZ #31968]H.J. Lu2024-08-011-1/+13
| | | | | | | | | | | | | Update the mremap C implementation to support the optional argument for MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct to implement a variadic function as a non-variadic function on all Linux targets. Return MAP_FAILED and set errno to EINVAL for unknown flag bits. This fixes BZ #31968. Note: A test must be added when a new flag bit is introduced. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Add F_DUPFD_QUERY from Linux 6.10 to bits/fcntl-linux.hAdhemerval Zanella2024-07-301-0/+1
| | | | | | | | It was added by commit c62b758bae6af16 as a way for userspace to check if two file descriptors refer to the same struct file. Checked on aarch64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Update kernel version to 6.10 in header constant testsAdhemerval Zanella2024-07-303-4/+4
| | | | | | | | | | This patch updates the kernel version in the tests tst-mman-consts.py, tst-mount-consts.py, and tst-pidfd-consts.py to 6.9. There are no new constants covered by these tests in 6.10. Tested with build-many-glibcs.py. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Update syscall lists for Linux 6.10Adhemerval Zanella2024-07-3027-3/+32
| | | | | | | | | | | | | | | Linux 6.10 changes for syscall are: * mseal for all architectures. * map_shadow_stack for x32. * Replace sync_file_range with sync_file_range2 for csky (which fixes a broken sync_file_range usage). Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Mitigation for "clone on sparc might fail with -EFAULT for no valid reason" ↵Michael Karcher2024-07-292-0/+6
| | | | | | | | | | | | | | | (bz 31394) It seems the kernel can not deal with uncommitted stack space in the area intended for the register window when executing the clone() system call. So create a nested frame (proxy for the kernel frame) and flush it from the processor to memory to force committing pages to the stack before invoking the system call. Bug: https://www.mail-archive.com/debian-glibc@lists.debian.org/msg62592.html Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31394 See-also: https://lore.kernel.org/sparclinux/62f9be9d-a086-4134-9a9f-5df8822708af@mkarcher.dialup.fu-berlin.de/ Signed-off-by: Michael Karcher <sourceware-bugzilla@mkarcher.dialup.fu-berlin.de> Reviewed-by: DJ Delorie <dj@redhat.com>
* x32/cet: Support shadow stack during startup for Linux 6.10H.J. Lu2024-07-253-3/+8
| | | | | | | | | | | | | | | | | | | | | | | Use RXX_LP in RTLD_START_ENABLE_X86_FEATURES. Support shadow stack during startup for Linux 6.10: commit 2883f01ec37dd8668e7222dfdb5980c86fdfe277 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Mar 15 07:04:33 2024 -0700 x86/shstk: Enable shadow stacks for x32 1. Add shadow stack support to x32 signal. 2. Use the 64-bit map_shadow_stack syscall for x32. 3. Set up shadow stack for x32. Add the map_shadow_stack system call to <fixup-asm-unistd.h> and regenerate arch-syscall.h. Tested on Intel Tiger Lake with CET enabled x32. There are no regressions with CET enabled x86-64. There are no changes in CET enabled x86-64 _dl_start_user. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* linux: Trivial test output fix in tst-pkeyAndreas K. Hüttel2024-07-191-1/+1
| | | | Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
* linux: Also check pkey_get for ENOSYS on tst-pkey (BZ 31996)Adhemerval Zanella2024-07-191-1/+7
| | | | | | | | | | | The powerpc pkey_get/pkey_set support was only added for 64-bit [1], and tst-pkey only checks if the support was present with pkey_alloc (which does not fail on powerpc32, at least running a 64-bit kernel). Checked on powerpc-linux-gnu. [1] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a803367bab167f5ec4fde1f0d0ec447707c29520 Reviewed-By: Andreas K. Huettel <dilfridge@gentoo.org>
* Fix usage of _STACK_GROWS_DOWN and _STACK_GROWS_UP defines [BZ 31989]John David Anglin2024-07-191-1/+1
| | | | | Signed-off-by: John David Anglin <dave.anglin@bell.net> Reviewed-By: Andreas K. Hüttel <dilfridge@gentoo.org>
* Linux: Make __rseq_size useful for feature detection (bug 31965)Florian Weimer2024-07-092-3/+30
| | | | | | | | | | | The __rseq_size value is now the active area of struct rseq (so 20 initially), not the full struct size including padding at the end (32 initially). Update misc/tst-rseq to print some additional diagnostics. Reviewed-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
* elf: Make dl-rseq-symbols Linux onlyAdhemerval Zanella2024-07-042-0/+68
| | | | | | And avoid a Hurd build failures. Checked on x86_64-linux-gnu.
* hppa/vdso: Provide 64-bit clock_gettime() vDSO onlyJohn David Anglin2024-07-021-3/+0
| | | | | | | | | | Adhemerval noticed that the gettimeofday() and 32-bit clock_gettime() vDSO calls won't be used by glibc on hppa, so there is no need to declare them. Both syscalls will be emulated by utilizing return values of the 64-bit clock_gettime() vDSO instead. Signed-off-by: Helge Deller <deller@gmx.de> Suggested-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
* posix: Fix pidfd_spawn/pidfd_spawnp leak if execve fails (BZ 31695)Adhemerval Zanella2024-06-251-7/+16
| | | | | | | | | | | | | | | | | If the pidfd_spawn/pidfd_spawnp helper process succeeds, but evecve fails for some reason (either with an invalid/non-existent, memory allocation, etc.) the resulting pidfd is never closed, nor returned to caller (so it can call close). Since the process creation failed, it should be up to posix_spawn to also, close the file descriptor in this case (similar to what it does to reap the process). This patch also changes the waitpid with waitid (P_PIDFD) for pidfd case, to avoid a possible pid re-use. Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* RISC-V: Execute a PAUSE hint in spin loopsChristoph Müllner2024-06-241-0/+3
| | | | | | | | | | | | | | | | The atomic_spin_nop() macro can be used to run arch-specific code in the body of a spin loop to potentially improve efficiency. RISC-V's Zihintpause extension includes a PAUSE instruction for this use-case, which is encoded as a HINT, which means that it behaves like a NOP on systems that don't implement Zihintpause. Binutils supports Zihintpause since 2.36, so this patch uses the ".insn" directive to keep the code compatible with older toolchains. Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
* hppa/vdso: Add wrappers for vDSO functionsJohn David Anglin2024-06-231-0/+12
| | | | | | | | | | | | The upcoming parisc (hppa) v6.11 Linux kernel will include vDSO support for gettimeofday(), clock_gettime() and clock_gettime64() syscalls for 32- and 64-bit userspace. The patch below adds the necessary glue code for glibc. Signed-off-by: Helge Deller <deller@gmx.de> Changes in v2: - add vsyscalls for 64-bit too
* Linux: Include <dl-symbol-redir-ifunc.h> in dl-sysdep.cFlorian Weimer2024-06-181-0/+1
| | | | | | | | | | The _dl_sysdep_parse_arguments function contains initalization of a large on-stack variable: dl_parse_auxv_t auxv_values = { 0, }; This uses a non-inline version of memset on powerpc64le-linux-gnu, so it must use the baseline memset.
* linux: add definitions for hugetlb page size encodingsCarlos Llamas2024-06-183-6/+45
| | | | | | | | | | | | | | | | | | | | | | A desired hugetlb page size can be encoded in the flags parameter of system calls such as mmap() and shmget(). The Linux UAPI headers have included explicit definitions for these encodings since v4.14. This patch adds these definitions that are used along with MAP_HUGETLB and SHM_HUGETLB flags as specified in the corresponding man pages. This relieves programs from having to duplicate and/or compute the encodings manually. Additionally, the filter on these definitions in tst-mman-consts.py is removed, as suggested by Florian. I then ran this tests successfully, confirming the alignment with the kernel headers. PASS: misc/tst-mman-consts original exit status 0 Signed-off-by: Carlos Llamas <cmllamas@google.com> Tested-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
* elf: Remove HWCAP_IMPORTANTStefan Liebler2024-06-182-5/+0
| | | | | | | Remove the definitions of HWCAP_IMPORTANT after removal of LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask. There HWCAP_IMPORTANT was used as default value. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Remove _DL_HWCAP_PLATFORMStefan Liebler2024-06-182-6/+0
| | | | | | Remove the definitions of _DL_HWCAP_PLATFORM as those are not used anymore after removal in elf/dl-cache.c:search_cache(). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Remove _dl_string_platformStefan Liebler2024-06-182-4/+0
| | | | | | | | | Despite of powerpc where the returned integer is stored in tcb, and the diagnostics output, there is no user anymore. Thus this patch removes the diagnostics output and _dl_string_platform for all other platforms. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Convert to autoconf 2.72 (vanilla release, no distribution patches)Andreas K. Hüttel2024-06-176-306/+300
| | | | | | | As discussed at the patch review meeting Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> Reviewed-by: Simon Chopin <simon.chopin@canonical.com>
* Implement C23 exp2m1, exp10m1Joseph Myers2024-06-1731-0/+430
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C23 adds various <math.h> function families originally defined in TS 18661-4. Add the exp2m1 and exp10m1 functions (exp2(x)-1 and exp10(x)-1, like expm1). As with other such functions, these use type-generic templates that could be replaced with faster and more accurate type-specific implementations in future. Test inputs are copied from those for expm1, plus some additions close to the overflow threshold (copied from exp2 and exp10) and also some near the underflow threshold. exp2m1 has the unusual property of having an input (M_MAX_EXP) where whether the function overflows (under IEEE semantics) depends on the rounding mode. Although these could reasonably be XFAILed in the testsuite (as we do in some cases for arguments very close to a function's overflow threshold when an error of a few ulps in the implementation can result in the implementation not agreeing with an ideal one on whether overflow takes place - the testsuite isn't smart enough to handle this automatically), since these functions aren't required to be correctly rounding, I made the implementation check for and handle this case specially. The Makefile ordering expected by lint-makefiles for the new functions is a bit peculiar, but I implemented it in this patch so that the test passes; I don't know why log2 also needed moving in one Makefile variable setting when it didn't in my previous patches, but the failure showed a different place was expected for that function as well. The powerpc64le IFUNC setup seems not to be as self-contained as one might hope; it shouldn't be necessary to add IFUNCs for new functions such as these simply to get them building, but without setting up IFUNCs for the new functions, there were undefined references to __GI___expm1f128 (that IFUNC machinery results in no such function being defined, but doesn't stop include/math.h from doing the redirection resulting in the exp2m1f128 and exp10m1f128 implementations expecting to call it). Tested for x86_64 and x86, and with build-many-glibcs.py.
* Implement C23 log10p1Joseph Myers2024-06-1731-0/+215
| | | | | | | | | | | | | | C23 adds various <math.h> function families originally defined in TS 18661-4. Add the log10p1 functions (log10(1+x): like log1p, but for base-10 logarithms). This is directly analogous to the log2p1 implementation (except that whereas log2p1 has a smaller underflow range than log1p, log10p1 has a larger underflow range). The test inputs are copied from those for log1p and log2p1, plus a few more inputs in that wider underflow range. Tested for x86_64 and x86, and with build-many-glibcs.py.