From 283b9330dfe7aea95d0fc62cc41d7edeffcee1a9 Mon Sep 17 00:00:00 2001 From: Arjun Shankar Date: Fri, 7 Mar 2025 16:32:17 +0100 Subject: [PATCH] nptl: Keep __rseq_size consistent (RHEL-65280) Resolves: RHEL-65280 --- glibc-RHEL-65280-7.patch | 138 +++++++++++++++++++++++++++++++++++++++ glibc.spec | 6 +- 2 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 glibc-RHEL-65280-7.patch diff --git a/glibc-RHEL-65280-7.patch b/glibc-RHEL-65280-7.patch new file mode 100644 index 0000000..464d16e --- /dev/null +++ b/glibc-RHEL-65280-7.patch @@ -0,0 +1,138 @@ +This reverts glibc-RHEL-65280-6.patch. + +diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c +index 20552b11843148fb..2f56281a02246a09 100644 +--- a/sysdeps/nptl/dl-tls_init_tp.c ++++ b/sysdeps/nptl/dl-tls_init_tp.c +@@ -46,8 +46,6 @@ rtld_mutex_dummy (pthread_mutex_t *lock) + + const unsigned int __rseq_flags; + +-size_t _rseq_align attribute_hidden; +- + void + __tls_pre_init_tp (void) + { +@@ -101,17 +99,12 @@ __tls_init_tp (void) + } + + { +- /* If the registration fails or is disabled by tunable, the public +- '__rseq_size' will be set to '0' regardless of the feature size of the +- allocated rseq area. An rseq area of at least 32 bytes is always +- allocated since application code is allowed to check the status of the +- rseq registration by reading the content of the 'cpu_id' field. */ + bool do_rseq = true; + #if HAVE_TUNABLES + do_rseq = TUNABLE_GET (rseq, int, NULL); + #endif +- if (!rseq_register_current_thread (pd, do_rseq)) +- _rseq_size = 0; ++ if (rseq_register_current_thread (pd, do_rseq)) ++ _rseq_size = RSEQ_AREA_SIZE_INITIAL_USED; + + #ifdef RSEQ_SIG + /* This should be a compile-time constant, but the current +diff --git a/sysdeps/unix/sysv/linux/dl-parse_auxv.h b/sysdeps/unix/sysv/linux/dl-parse_auxv.h +index 44c135c56570134e..bf9374371eb217fc 100644 +--- a/sysdeps/unix/sysv/linux/dl-parse_auxv.h ++++ b/sysdeps/unix/sysv/linux/dl-parse_auxv.h +@@ -21,7 +21,6 @@ + #include + #include + #include +-#include + + typedef ElfW(Addr) dl_parse_auxv_t[AT_MINSIGSTKSZ + 1]; + +@@ -58,17 +57,5 @@ void _dl_parse_auxv (ElfW(auxv_t) *av, dl_parse_auxv_t auxv_values) + GLRO(dl_sysinfo) = auxv_values[AT_SYSINFO]; + #endif + +- /* Get the rseq feature size, with a minimum of RSEQ_AREA_SIZE_INITIAL_USED +- (20) for kernels that don't have AT_RSEQ_FEATURE_SIZE. Limit the feature +- size to RSEQ_AREA_SIZE_MAX_USED (28) which fits the rseq area in 'struct +- pthread' and represents the maximum feature size of currently released +- kernels. Since no kernels currently cross the 32 bytes of the original +- ABI, the semantics of a feature size of 32 or more are still undetermined. +- */ +- _rseq_size = MIN (MAX (auxv_values[AT_RSEQ_FEATURE_SIZE], +- RSEQ_AREA_SIZE_INITIAL_USED), +- RSEQ_AREA_SIZE_MAX_USED); +- _rseq_align = MAX (auxv_values[AT_RSEQ_ALIGN], RSEQ_MIN_ALIGN); +- + DL_PLATFORM_AUXV + } +diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h +index f4027b09519a652b..c108a12a6227eeac 100644 +--- a/sysdeps/unix/sysv/linux/rseq-internal.h ++++ b/sysdeps/unix/sysv/linux/rseq-internal.h +@@ -25,31 +25,13 @@ + #include + #include + +-/* Minimum size of the rseq area allocation required by the syscall. The +- actually used rseq feature size may be less (20 bytes initially). */ ++/* 32 is the initially required value for the area size. The ++ actually used rseq size may be less (20 bytes initially). */ + #define RSEQ_AREA_SIZE_INITIAL 32 +- +-/* Minimum used feature size of the rseq area. */ + #define RSEQ_AREA_SIZE_INITIAL_USED 20 + +-/* Maximum currently used feature size of the rseq area. */ +-#define RSEQ_AREA_SIZE_MAX_USED 28 +- +-/* Minimum alignment of the rseq area. */ +-#define RSEQ_MIN_ALIGN 32 +- +-/* Alignment requirement of the rseq area. +- Populated from the auxiliary vector with a minimum of '32'. +- In .data.relro but not yet write-protected. */ +-extern size_t _rseq_align attribute_hidden; +- +-/* Size of the active features in the rseq area. +- Populated from the auxiliary vector with a minimum of '20'. +- In .data.relro but not yet write-protected. */ ++/* The variables are in .data.relro but are not yet write-protected. */ + extern unsigned int _rseq_size attribute_hidden; +- +-/* Offset from the thread pointer to the rseq area. +- In .data.relro but not yet write-protected. */ + extern ptrdiff_t _rseq_offset attribute_hidden; + + #ifdef RSEQ_SIG +diff --git a/sysdeps/unix/sysv/linux/tst-rseq.c b/sysdeps/unix/sysv/linux/tst-rseq.c +index 5946db73d9b079c3..1d404db610c08fdf 100644 +--- a/sysdeps/unix/sysv/linux/tst-rseq.c ++++ b/sysdeps/unix/sysv/linux/tst-rseq.c +@@ -38,15 +38,13 @@ static void + do_rseq_main_test (void) + { + struct pthread *pd = THREAD_SELF; +- size_t rseq_feature_size = MIN (MAX (getauxval (AT_RSEQ_FEATURE_SIZE), +- RSEQ_AREA_SIZE_INITIAL_USED), +- RSEQ_AREA_SIZE_MAX_USED); + + TEST_VERIFY_EXIT (rseq_thread_registered ()); + TEST_COMPARE (__rseq_flags, 0); + TEST_VERIFY ((char *) __thread_pointer () + __rseq_offset + == (char *) &pd->rseq_area); +- TEST_COMPARE (__rseq_size, rseq_feature_size); ++ /* The current implementation only supports the initial size. */ ++ TEST_COMPARE (__rseq_size, 20); + } + + static void +diff --git a/sysdeps/unix/sysv/linux/tst-rseq.h b/sysdeps/unix/sysv/linux/tst-rseq.h +index 86cf50fbeff32384..a476c316fc2671a0 100644 +--- a/sysdeps/unix/sysv/linux/tst-rseq.h ++++ b/sysdeps/unix/sysv/linux/tst-rseq.h +@@ -23,7 +23,6 @@ + #include + #include + #include +-#include + + static inline bool + rseq_thread_registered (void) diff --git a/glibc.spec b/glibc.spec index d107e00..0b9be48 100644 --- a/glibc.spec +++ b/glibc.spec @@ -157,7 +157,7 @@ end \ Summary: The GNU libc libraries Name: glibc Version: %{glibcversion} -Release: 173%{?dist} +Release: 174%{?dist} # In general, GPLv2+ is used by programs, LGPLv2+ is used for # libraries. @@ -1129,6 +1129,7 @@ Patch821: glibc-RHEL-65280-3.patch Patch822: glibc-RHEL-65280-4.patch Patch823: glibc-RHEL-65280-5.patch Patch824: glibc-RHEL-65280-6.patch +Patch825: glibc-RHEL-65280-7.patch ############################################################################## # Continued list of core "glibc" package information: @@ -3122,6 +3123,9 @@ update_gconv_modules_cache () %endif %changelog +* Fri Mar 07 2025 Arjun Shankar - 2.34-174 +- nptl: Keep __rseq_size consistent (RHEL-65280) + * Thu Mar 06 2025 Arjun Shankar - 2.34-173 - Make __rseq_size useful for feature detection (RHEL-65280)