aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-04-11loongarch: Fix Race conditions in pthread cancellation [BZ#12683]azanella/bz12683Adhemerval Zanella1-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.
2023-04-10or1k: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-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.
2023-04-10mips: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella9-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.
2023-04-10csky: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+114
By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for csky-linux-gnuabiv2.
2023-04-10alpha: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+80
By adding the required syscall_cancel.S. Checked on alpha-linux-gnu.
2023-04-10m68k: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+84
By adding the required syscall_cancel.S. Checked on m68k-linux-gnu.
2023-04-10hppa: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+81
By adding the required syscall_cancel.S. Checked on hppa-linux-gnu.
2023-04-10microblaze: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+61
By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for microblaze-linux-gnu.
2023-04-10nios2: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+95
By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for nios2-linux-gnu.
2023-04-10sh: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2-0/+127
By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for sh4-linux-gnu.
2023-04-10ia64: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2-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.
2023-04-10arc: Fix Race conditions in pthread cancellation [BZ #12683]Adhemerval Zanella1-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.
2023-04-10riscv: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+67
By adding the required syscall_cancel.S. Reviewed-by: Andrew Waterman <aswaterman@gmail.com>
2023-04-10s390: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2-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>
2023-04-10sparc: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2-0/+145
By adding the required syscall_cancel.S. Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
2023-04-10powerpc: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella3-0/+87
By adding the required syscall_cancel.S. Checked on powerpc64le-linux-gnu, powerpc64-linux-gnu and powerpc-linux-gnu.
2023-04-10arm: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+78
By adding the required syscall_cancel.S. Checked on arm-linux-gnueabihf.
2023-04-10aarch64: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+59
By adding the required syscall_cancel.S. Checked on aarch64-linux-gnu.
2023-04-10i386: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-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
2023-04-10x32: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella1-0/+34
By adding a x86_64-x32 __SSC macro. Checked on x86_64-linux-gnu-x32.
2023-04-10x86_64: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2-3/+57
By adding the required syscall_cancel.S. Checked on x86_64-linux-gnu.
2023-04-10nptl: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella21-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.
2023-04-06<stdio.h>: Make fopencookie, vasprintf, asprintf available by defaultFlorian Weimer1-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>
2023-04-06<string.h>: Make strchrnul, strcasestr, memmem available by defaultFlorian Weimer1-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>
2023-04-05<sys/platform/x86.h>: Add PREFETCHI supportH.J. Lu5-0/+10
Add PREFETCHI support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add AMX-COMPLEX supportH.J. Lu5-0/+11
Add AMX-COMPLEX support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add AVX-NE-CONVERT supportH.J. Lu5-0/+11
Add AVX-NE-CONVERT support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add AVX-VNNI-INT8 supportH.J. Lu5-0/+20
Add AVX-VNNI-INT8 support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add MSRLIST supportH.J. Lu3-0/+6
Add MSRLIST support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add AVX-IFMA supportH.J. Lu5-0/+11
Add AVX-IFMA support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add AMX-FP16 supportH.J. Lu5-0/+11
Add AMX-FP16 support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add WRMSRNS supportH.J. Lu3-0/+5
Add WRMSRNS support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add ArchPerfmonExt supportH.J. Lu3-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>
2023-04-05<sys/platform/x86.h>: Add CMPCCXADD supportH.J. Lu5-0/+10
Add CMPCCXADD support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add LASS supportH.J. Lu3-0/+5
Add Linear Address Space Separation (LASS) support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add RAO-INT supportH.J. Lu5-0/+10
Add RAO-INT support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add LBR supportH.J. Lu3-1/+5
Add architectural LBR support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add RTM_FORCE_ABORT supportH.J. Lu3-1/+5
Add RTM_FORCE_ABORT support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add SGX-KEYS supportH.J. Lu3-1/+5
Add SGX-KEYS support to <sys/platform/x86.h>. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<sys/platform/x86.h>: Add BUS_LOCK_DETECT supportH.J. Lu3-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>
2023-04-05<sys/platform/x86.h>: Add LA57 supportH.J. Lu3-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>
2023-04-05platform.texi: Move LAM after LAHF64_SAHF64H.J. Lu1-3/+3
Move LAM after LAHF64_SAHF64 to sort x86 features. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-05<bits/platform/x86.h>: Rename to x86_cpu_INDEX_7_ECX_15H.J. Lu1-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>
2023-04-05hppa: Update struct __pthread_rwlock_arch_t comment.John David Anglin1-5/+5
Signed-off-by: John David Anglin <dave.anglin@bell.net>
2023-04-05hppa: Revise __TIMESIZE define to use __WORDSIZEJohn David Anglin1-1/+3
Handle both 32 and 64-bit ABIs. Signed-off-by: John David Anglin <dave.anglin@bell.net>
2023-04-05libio: Remove unused pragma weak on vtableAdhemerval Zanella1-2/+0
Both _IO_file_jumps_alias and _IO_wfile_jumps_alias are defined as alias.
2023-04-05malloc: Only set pragma weak for rpc freemem if requiredAdhemerval Zanella1-2/+4
Both __rpc_freemem and __rpc_thread_destroy are only used if the the compat symbols are required.
2023-04-05htl: move pthread_self info libc.Guy-Fleury Iteriteka9-16/+18
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230318095826.1125734-4-gfleury@disroot.org>
2023-04-05htl: move ___pthread_self into libc.Guy-Fleury Iteriteka5-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>
2023-04-05htl: move __pthtread_total into libcGuy-Fleury Iteriteka5-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>