glibc/sysdeps
Adhemerval Zanella a6fbe36b7f nptl: Add support for setup guard pages with MADV_GUARD_INSTALL
Linux 6.13 (662df3e5c3766) added a lightweight way to define guard areas
through madvise syscall.  Instead of PROT_NONE the guard region through
mprotect, userland can madvise the same area with a special flag, and
the kernel ensures that accessing the area will trigger a SIGSEGV (as for
PROT_NONE mapping).

The madvise way has the advantage of less kernel memory consumption for
the process page-table (one less VMA per guard area), and slightly less
contention on kernel (also due to the fewer VMA areas being tracked).

The pthread_create allocates a new thread stack in two ways: if a guard
area is set (the default) it allocates the memory range required using
PROT_NONE and then mprotect the usable stack area. Otherwise, if a
guard page is not set it allocates the region with the required flags.

For the MADV_GUARD_INSTALL support, the stack area region is allocated
with required flags and then the guard region is installed.  If the
kernel does not support it, the usual way is used instead (and
MADV_GUARD_INSTALL is disabled for future stack creations).

The stack allocation strategy is recorded on the pthread struct, and it
is used in case the guard region needs to be resized.  To avoid needing
an extra field, the 'user_stack' is repurposed and renamed to 'stack_mode'.

This patch also adds a proper test for the pthread guard.

I checked on x86_64, aarch64, powerpc64le, and hppa with kernel 6.13.0-rc7.

Reviewed-by: DJ Delorie <dj@redhat.com>
2025-01-30 10:16:37 -03:00
..
aarch64 aarch64: Fix tests not compatible with targets supporting GCS 2025-01-20 09:36:19 +00:00
alpha math: update alpha ulps 2025-01-05 20:02:53 +01:00
arc arc: Update libm test ulps 2025-01-15 11:41:30 +00:00
arm math: update arm ulps 2025-01-17 19:36:22 +00:00
csky Move <thread_pointer.h> to kernel-independent sysdeps directories 2025-01-09 19:30:16 +01:00
generic Add generic 'extra TLS' 2025-01-10 20:19:28 +00:00
gnu Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
hppa Move <thread_pointer.h> to kernel-independent sysdeps directories 2025-01-09 19:30:16 +01:00
htl htl: move pthread_setcanceltype into libc. 2025-01-29 02:32:36 +01:00
hurd Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
i386 i386: Update ulps for *pi functions 2025-01-20 11:34:38 +01:00
ieee754 math: Fix acosf when building with gcc <= 11 2025-01-09 12:53:58 -03:00
loongarch Move <thread_pointer.h> to kernel-independent sysdeps directories 2025-01-09 19:30:16 +01:00
m68k Add missing include guards to <dl-tls.h> 2025-01-10 19:02:47 +01:00
mach htl: move pthread_setcanceltype into libc. 2025-01-29 02:32:36 +01:00
microblaze Move <thread_pointer.h> to kernel-independent sysdeps directories 2025-01-09 19:30:16 +01:00
mips Add missing include guards to <dl-tls.h> 2025-01-10 19:02:47 +01:00
nptl nptl: Add support for setup guard pages with MADV_GUARD_INSTALL 2025-01-30 10:16:37 -03:00
or1k Move <thread_pointer.h> to kernel-independent sysdeps directories 2025-01-09 19:30:16 +01:00
posix Fix underallocation of abort_msg_s struct (CVE-2025-0395) 2025-01-22 08:17:17 -05:00
powerpc Move <thread_pointer.h> to kernel-independent sysdeps directories 2025-01-09 19:30:16 +01:00
pthread Add new tests for fopen 2025-01-28 12:50:50 -05:00
riscv Add missing include guards to <dl-tls.h> 2025-01-10 19:02:47 +01:00
s390 Add missing include guards to <dl-tls.h> 2025-01-10 19:02:47 +01:00
sh elf: Introduce generic <dl-tls.h> 2025-01-02 13:45:27 +01:00
sparc Move <thread_pointer.h> to kernel-independent sysdeps directories 2025-01-09 19:30:16 +01:00
unix nptl: Add support for setup guard pages with MADV_GUARD_INSTALL 2025-01-30 10:16:37 -03:00
wordsize-32 Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
wordsize-64 Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
x86 x86: Add missing #include <features.h> to <thread_pointer.h> 2025-01-09 19:30:41 +01:00
x86_64 x86-64: Cast __rseq_offset to long long int [BZ #32543] 2025-01-12 07:08:27 +08:00