aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach
AgeCommit message (Collapse)AuthorFilesLines
2025-01-02htl: move pthread_mutexattr_setprotocol into libc.Samuel Thibault5-4/+13
Message-ID: <20241231134909.1166440-5-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_getprotocol into libc.gfleury5-4/+13
Message-ID: <20241231134909.1166440-4-gfleury@disroot.org>
2025-01-01htl: move pthread_mutexattr_destroy into libc.gfleury5-3/+3
Message-ID: <20241231134909.1166440-3-gfleury@disroot.org>
2025-01-01htl: move pthread_mutexattr_init into libc.gfleury5-2/+3
Message-ID: <20241231134909.1166440-2-gfleury@disroot.org>
2025-01-01bits/socket.h: Update to recent BSD definitionSamuel Thibault1-8/+4
The old BSD 4.4 definition (not used by Linux) was not 64b-proof: the cmsg_data field is supposed to CMSG_ALIGN'ed (as can be also seen in the CMSG_LEN macro). Suggested-by: Diego Nieto Cid <dnietoc@gmail.com>
2025-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert423-423/+423
2024-12-31elf: Do not change stack permission on dlopen/dlmopenAdhemerval Zanella2-1/+2
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-27hurd: Avoid asm statements which returnSamuel Thibault5-67/+96
They are not supposed to change flow control. This fixes miscompilation with gcc 14.2.0 which then drops code, see https://lists.gnu.org/archive/html/bug-hurd/2024-11/msg00145.html
2024-12-22htl: move pthread_cond_timedwait, pthread_cond_clockwait, pthread_cond_wait ↵gfleury4-6/+4
into libc. Message-ID: <20241219203727.669825-9-gfleury@disroot.org>
2024-12-22htl: move __pthread_mutex_checklocked into libc.gfleury8-2/+8
move out __getpid from pt-mutex.h and in pt-mutex-* include <unistd.h> where __getpid was called Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-8-gfleury@disroot.org>
2024-12-22htl: move __pthread_timedblock, __pthread_timedblock_intr, __pthread_block, ↵gfleury2-0/+2
__pthread_block_intr into libc. Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-7-gfleury@disroot.org>
2024-12-22htl: move pthread_cond_signal into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-6-gfleury@disroot.org>
2024-12-22htl: move pthread_cond_broadcast into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-5-gfleury@disroot.org>
2024-12-22htl: move pthread_cond_destroy into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-4-gfleury@disroot.org>
2024-12-22htl: move __pthread_wakeup into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-3-gfleury@disroot.org>
2024-12-22htl: move pthread_cond_init into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-2-gfleury@disroot.org>
2024-12-22hurd: make mprotect translate KERN_PROTECTION_FAILURE to EACCESSSamuel Thibault1-0/+3
Suggested-by: Sergey Bugaev <bugaevc@gmail.com>
2024-12-14htl: move pthread_sigmask into libc.gfleury5-6/+8
Message-ID: <20241212220612.782313-3-gfleury@disroot.org>
2024-12-14htl: move __pthread_sigstate into libc.gfleury1-0/+1
Message-ID: <20241212220612.782313-2-gfleury@disroot.org>
2024-12-14htl: move __pthread_sigstate_destroy into libc.gfleury1-0/+1
Message-ID: <20241212220612.782313-1-gfleury@disroot.org>
2024-12-12Implement C23 atan2piJoseph Myers2-0/+16
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 Myers2-0/+16
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-10Implement C23 asinpiJoseph Myers2-0/+16
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 Myers2-0/+16
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-09htl: move pthread_condattr_setpshared into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241126205329.2215295-8-gfleury@disroot.org>
2024-12-09htl: move pthread_condattr_setclock into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241126205329.2215295-7-gfleury@disroot.org>
2024-12-09htl: move pthread_condattr_init into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241126205329.2215295-6-gfleury@disroot.org>
2024-12-09htl: move pthread_condattr_getpshared into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241126205329.2215295-5-gfleury@disroot.org>
2024-12-09htl: move pthread_condattr_getclock into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241126205329.2215295-4-gfleury@disroot.org>
2024-12-09htl: move pthread_condattr_destroy into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241126205329.2215295-2-gfleury@disroot.org>
2024-12-05Implement C23 tanpiJoseph Myers2-0/+16
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.
2024-12-04Implement C23 sinpiJoseph Myers2-0/+16
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the sinpi functions (sin(pi*x)). Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-04Implement C23 cospiJoseph Myers2-0/+16
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the cospi functions (cos(pi*x)). Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-11-25hurd: Add MAP_NORESERVE mmap flagSamuel Thibault1-0/+1
This is already the current default behavior, which we will change with overcommit support addition.
2024-11-19htl: move pthread_attr_init into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setguardsize into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setschedparam into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setscope into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setstackaddr into libc.gfleury4-4/+8
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setstacksize into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_getstack into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_getstackaddr into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl move pthread_attr_getstacksize into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl move pthread_attr_getscope into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl move pthread_attr_getguardsize into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_destroy into libc.gfleury3-2/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-13Revert "hurd: Stop depending on the default_pager stubs provided by gnumach"Samuel Thibault2-2/+4
This reverts commit f7f7dd8009275504b211c170caf5bce50fa472ac. default_pager is actually also used in e.g. xosview.
2024-11-12linux: Add support for getrandom vDSOAdhemerval Zanella1-1/+3
Linux 6.11 has getrandom() in vDSO. It operates on a thread-local opaque state allocated with mmap using flags specified by the vDSO. Multiple states are allocated at once, as many as fit into a page, and these are held in an array of available states to be doled out to each thread upon first use, and recycled when a thread terminates. As these states run low, more are allocated. To make this procedure async-signal-safe, a simple guard is used in the LSB of the opaque state address, falling back to the syscall if there's reentrancy contention. Also, _Fork() is handled by blocking signals on opaque state allocation (so _Fork() always sees a consistent state even if it interrupts a getrandom() call) and by iterating over the thread stack cache on reclaim_stack. Each opaque state will be in the free states list (grnd_alloc.states) or allocated to a running thread. The cancellation is handled by always using GRND_NONBLOCK flags while calling the vDSO, and falling back to the cancellable syscall if the kernel returns EAGAIN (would block). Since getrandom is not defined by POSIX and cancellation is supported as an extension, the cancellation is handled as 'may occur' instead of 'shall occur' [1], meaning that if vDSO does not block (the expected behavior) getrandom will not act as a cancellation entrypoint. It avoids a pthread_testcancel call on the fast path (different than 'shall occur' functions, like sem_wait()). It is currently enabled for x86_64, which is available in Linux 6.11, and aarch64, powerpc32, powerpc64, loongarch64, and s390x, which are available in Linux 6.12. Link: https://pubs.opengroup.org/onlinepubs/9799919799/nframe.html [1] Co-developed-by: Jason A. Donenfeld <Jason@zx2c4.com> Tested-by: Jason A. Donenfeld <Jason@zx2c4.com> # x86_64 Tested-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> # x86_64, aarch64 Tested-by: Xi Ruoyao <xry111@xry111.site> # x86_64, aarch64, loongarch64 Tested-by: Stefan Liebler <stli@linux.ibm.com> # s390x
2024-11-09mach: Fix __xpg_strerror_r on in-range but undefined errors [BZ #32350]Samuel Thibault1-2/+12
For instance, 1073741906 leads to system 16, subsystem 0 and code 82, which is in range (max_code is 122), but not defined. Return EINVAL in that case, like
2024-10-09Fix header guard in sysdeps/mach/hurd/x86_64/vm_param.hJoseph Myers1-1/+1
GCC mainline produces a -Wheader-guard error building for x86_64-gnu. Fix what seems to be incorrect macro naming in the #ifndef conditional. Tested with build-many-glibc.py for x86_64-gnu (GCC mainline). Message-ID: <fd800046-5ecb-ebd5-4df1-29d4eb3d5433@redhat.com>