summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* loongarch: Fix Race conditions in pthread cancellation [BZ#12683]azanella/bz12683Adhemerval Zanella2023-04-111-0/+50
| | | | | | | By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for loongarch64-linux-gnu-lp64d.
* or1k: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+63
| | | | | | | By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for or1k-linux-gnu-soft.
* mips: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-109-56/+354
| | | | | | | | | | | | | | It adds the arch-specific cancellation syscall bridge and adjust the cancellable syscall bridge to accept 7 arguments (as required by mips o32). To avoid add a requirement on all architectures to support {INLINE,INTERNAL)_SYSCALL with 7 argument, mips support is added through a flag, HAVE_CANCELABLE_SYSCALL_WITH_7_ARGS, which changes the signature and prototype of the requires macros and functions (SYSCALL_CANCEL, __syscall_cancel and __syscall_cancel_arch). Checked on mips-linux-gnu, mips64-linux-gnu, and mips64-n32-linux-gnu.
* csky: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+114
| | | | | | | By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for csky-linux-gnuabiv2.
* alpha: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+80
| | | | | | By adding the required syscall_cancel.S. Checked on alpha-linux-gnu.
* m68k: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+84
| | | | | | By adding the required syscall_cancel.S. Checked on m68k-linux-gnu.
* hppa: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+81
| | | | | | By adding the required syscall_cancel.S. Checked on hppa-linux-gnu.
* microblaze: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+61
| | | | | | | By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for microblaze-linux-gnu.
* nios2: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+95
| | | | | | | By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for nios2-linux-gnu.
* sh: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-102-0/+127
| | | | | | | By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for sh4-linux-gnu.
* ia64: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-102-0/+129
| | | | | | | | | | | | | | | The syscall bridge uses the old brk 0x10000 instruction because by using the vDSO gate the resulting PC value for an interrupted syscall points to an address outside the expected markers in __syscall_cancel_arch. This is similar to i686 issue. Also the __syscall_cancel_arch issues the 'break 0x100000' on its own bundle, and __syscall_cancel_arch_end points to end of the previous one. It requires an arch-specific ucontext_check_pc_boundary to check for the ri value (embedded in the sc_ip by the kernel) to check if the syscall had any side-effects. Checked on ia64-linux-gnu.
* arc: Fix Race conditions in pthread cancellation [BZ #12683]Adhemerval Zanella2023-04-101-0/+56
| | | | | | | By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for arc-linux-gnu, arc-linux-gnuhf, and arceb-linux-gnu.
* riscv: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+67
| | | | | | By adding the required syscall_cancel.S. Reviewed-by: Andrew Waterman <aswaterman@gmail.com>
* s390: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-102-0/+124
| | | | | | | | By adding the required syscall_cancel.S. Checked on s390-linux-gnu and s390x-linux-gnu. Co-authored-by: Stefan Liebler <stli@linux.ibm.com>
* sparc: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-102-0/+145
| | | | | | By adding the required syscall_cancel.S. Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
* powerpc: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-103-0/+87
| | | | | | | By adding the required syscall_cancel.S. Checked on powerpc64le-linux-gnu, powerpc64-linux-gnu and powerpc-linux-gnu.
* arm: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+78
| | | | | | By adding the required syscall_cancel.S. Checked on arm-linux-gnueabihf.
* aarch64: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+59
| | | | | | By adding the required syscall_cancel.S. Checked on aarch64-linux-gnu.
* i386: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+103
| | | | | | | | | | | | | | | | | The syscall bridge uses the old int80 instruction because by using the optimized vDSO symbol the resulting PC value for an interrupted syscall points to an adress 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). Checked on i686-linux-gnu. [1] https://lkml.org/lkml/2016/3/8/1105
* x32: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-101-0/+34
| | | | | | By adding a x86_64-x32 __SSC macro. Checked on x86_64-linux-gnu-x32.
* x86_64: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-102-3/+57
| | | | | | By adding the required syscall_cancel.S. Checked on x86_64-linux-gnu.
* nptl: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2023-04-1021-196/+525
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: 1. Before the final "testcancel" and before the syscall is made. 2. Between the "testcancel" and the syscall. 3. While the syscall is blocked and no side effects have yet taken place. 4. While the syscall is blocked but with some side effects already having taken place (e.g. a partial read or write). 5. After the syscall has returned. 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. 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. 4. 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). 5. 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 appropriated cancelable syscalls. 5. Adjust 'lowlevellock-futex.h' arch-specific implementations to provide cancelable futex calls. This patch adds the proposed changes to NPTL common code and the following patches add the requires arch-specific bits. The build for ia64-linux-gnu, mips-*, and x86_64-* are broken without the arch-specific patches.
* <stdio.h>: Make fopencookie, vasprintf, asprintf available by defaultFlorian Weimer2023-04-061-3/+3
| | | | | | | FreeBSD makes these functions available by default, so we should not treat them as GNU-specific and restrict them to _GNU_SOURCE. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* <string.h>: Make strchrnul, strcasestr, memmem available by defaultFlorian Weimer2023-04-061-3/+3
| | | | | | | FreeBSD makes them available by default, too, so there does not seem to be a reason to restrict these functions to _GNU_SOURCE. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* <sys/platform/x86.h>: Add PREFETCHI supportH.J. Lu2023-04-055-0/+10
| | | | | Add PREFETCHI support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add AMX-COMPLEX supportH.J. Lu2023-04-055-0/+11
| | | | | Add AMX-COMPLEX support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add AVX-NE-CONVERT supportH.J. Lu2023-04-055-0/+11
| | | | | Add AVX-NE-CONVERT support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add AVX-VNNI-INT8 supportH.J. Lu2023-04-055-0/+20
| | | | | Add AVX-VNNI-INT8 support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add MSRLIST supportH.J. Lu2023-04-053-0/+6
| | | | | Add MSRLIST support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add AVX-IFMA supportH.J. Lu2023-04-055-0/+11
| | | | | Add AVX-IFMA support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add AMX-FP16 supportH.J. Lu2023-04-055-0/+11
| | | | | Add AMX-FP16 support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add WRMSRNS supportH.J. Lu2023-04-053-0/+5
| | | | | Add WRMSRNS support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add ArchPerfmonExt supportH.J. Lu2023-04-053-0/+6
| | | | | | Add Architectural Performance Monitoring Extended Leaf (EAX = 23H) support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add CMPCCXADD supportH.J. Lu2023-04-055-0/+10
| | | | | Add CMPCCXADD support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add LASS supportH.J. Lu2023-04-053-0/+5
| | | | | Add Linear Address Space Separation (LASS) support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add RAO-INT supportH.J. Lu2023-04-055-0/+10
| | | | | Add RAO-INT support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add LBR supportH.J. Lu2023-04-053-1/+5
| | | | | Add architectural LBR support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add RTM_FORCE_ABORT supportH.J. Lu2023-04-053-1/+5
| | | | | Add RTM_FORCE_ABORT support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add SGX-KEYS supportH.J. Lu2023-04-053-1/+5
| | | | | Add SGX-KEYS support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add BUS_LOCK_DETECT supportH.J. Lu2023-04-053-1/+5
| | | | | | Add Bus lock debug exceptions (BUS_LOCK_DETECT) support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <sys/platform/x86.h>: Add LA57 supportH.J. Lu2023-04-053-1/+5
| | | | | | Add 57-bit linear addresses and five-level paging (LA57) support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* platform.texi: Move LAM after LAHF64_SAHF64H.J. Lu2023-04-051-3/+3
| | | | | Move LAM after LAHF64_SAHF64 to sort x86 features. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* <bits/platform/x86.h>: Rename to x86_cpu_INDEX_7_ECX_15H.J. Lu2023-04-051-1/+1
| | | | | | Rename x86_cpu_INDEX_7_ECX_1 to x86_cpu_INDEX_7_ECX_15 for the unused bit 15 in ECX from CPUID with EAX == 0x7 and ECX == 0. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* hppa: Update struct __pthread_rwlock_arch_t comment.John David Anglin2023-04-051-5/+5
| | | | Signed-off-by: John David Anglin <dave.anglin@bell.net>
* hppa: Revise __TIMESIZE define to use __WORDSIZEJohn David Anglin2023-04-051-1/+3
| | | | | | Handle both 32 and 64-bit ABIs. Signed-off-by: John David Anglin <dave.anglin@bell.net>
* libio: Remove unused pragma weak on vtableAdhemerval Zanella2023-04-051-2/+0
| | | | | Both _IO_file_jumps_alias and _IO_wfile_jumps_alias are defined as alias.
* malloc: Only set pragma weak for rpc freemem if requiredAdhemerval Zanella2023-04-051-2/+4
| | | | | Both __rpc_freemem and __rpc_thread_destroy are only used if the the compat symbols are required.
* htl: move pthread_self info libc.Guy-Fleury Iteriteka2023-04-059-16/+18
| | | | | Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230318095826.1125734-4-gfleury@disroot.org>
* htl: move ___pthread_self into libc.Guy-Fleury Iteriteka2023-04-055-3/+27
| | | | | | | | | | | sysdeps/mach/hurd/htl/pt-pthread_self.c: New file. htl/Makefile: .. Add it to libc routine. sysdeps/mach/hurd/htl/pt-sysdep.c(__pthread_self): Remove it. sysdeps/mach/hurd/htl/pt-sysdep.h(__pthread_self): Add hidden propertie. htl/Versions(__pthread_self) Version it as private symbol. Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230318095826.1125734-3-gfleury@disroot.org>
* htl: move __pthtread_total into libcGuy-Fleury Iteriteka2023-04-055-7/+26
| | | | | | | | | | | htl/pt-nthreads.c: new file. htl/Makefile: Add it to routine. htl/Versions: version it as private libc symbol. htl/pt-create.c: remove his definition here. htl/pt-internal.h: add propertie to it declaration. Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230318095826.1125734-2-gfleury@disroot.org>