rseq_area should always be 32 bytes large (#2224289)

Resolves: #2224289
This commit is contained in:
Florian Weimer 2023-07-21 16:30:40 +02:00
parent 370cf824b2
commit 86889b9545
3 changed files with 94 additions and 1 deletions

32
glibc-rh2224289-1.patch Normal file
View File

@ -0,0 +1,32 @@
commit 3edc4ff2ceff4a59587ebecb94148d3bcfa1df62
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed Jul 19 14:09:26 2023 -0700
make struct pthread a complete type
* nptl/descr.h (struct pthread): Remove end_padding member, which
made this type incomplete.
(PTHREAD_STRUCT_END_PADDING): Stop using end_padding.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
diff --git a/nptl/descr.h b/nptl/descr.h
index dfef9c4bda075d13..c487846c171f9434 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -412,11 +412,11 @@ struct pthread
/* rseq area registered with the kernel. */
struct rseq rseq_area;
- /* This member must be last. */
- char end_padding[];
-
+ /* Amount of end padding, if any, in this structure.
+ This definition relies on rseq_area being last. */
#define PTHREAD_STRUCT_END_PADDING \
- (sizeof (struct pthread) - offsetof (struct pthread, end_padding))
+ (sizeof (struct pthread) - offsetof (struct pthread, rseq_area) \
+ + sizeof (struct rseq))
} __attribute ((aligned (TCB_ALIGNMENT)));
static inline bool

56
glibc-rh2224289-2.patch Normal file
View File

@ -0,0 +1,56 @@
commit 2c6b4b272e6b4d07303af25709051c3e96288f2d
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Jul 21 16:18:18 2023 +0200
nptl: Unconditionally use a 32-byte rseq area
If the kernel headers provide a larger struct rseq, we used that
size as the argument to the rseq system call. As a result,
rseq registration would fail on older kernels which only accept
size 32.
Conflicts:
nptl/descr.h
(upstream has an additional #include <internal-sigset.h>)
diff --git a/nptl/descr.h b/nptl/descr.h
index c487846c171f9434..eded9eca38e7275e 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -35,7 +35,6 @@
#include <bits/types/res_state.h>
#include <kernel-features.h>
#include <tls-internal-struct.h>
-#include <sys/rseq.h>
#ifndef TCB_ALIGNMENT
# define TCB_ALIGNMENT 32
@@ -409,14 +408,25 @@ struct pthread
/* Used on strsignal. */
struct tls_internal_t tls_state;
- /* rseq area registered with the kernel. */
- struct rseq rseq_area;
+ /* rseq area registered with the kernel. Use a custom definition
+ here to isolate from kernel struct rseq changes. The
+ implementation of sched_getcpu needs acccess to the cpu_id field;
+ the other fields are unused and not included here. */
+ union
+ {
+ struct
+ {
+ uint32_t cpu_id_start;
+ uint32_t cpu_id;
+ };
+ char pad[32]; /* Original rseq area size. */
+ } rseq_area __attribute__ ((aligned (32)));
/* Amount of end padding, if any, in this structure.
This definition relies on rseq_area being last. */
#define PTHREAD_STRUCT_END_PADDING \
(sizeof (struct pthread) - offsetof (struct pthread, rseq_area) \
- + sizeof (struct rseq))
+ + sizeof ((struct pthread) {}.rseq_area))
} __attribute ((aligned (TCB_ALIGNMENT)));
static inline bool

View File

@ -155,7 +155,7 @@ end \
Summary: The GNU libc libraries Summary: The GNU libc libraries
Name: glibc Name: glibc
Version: %{glibcversion} Version: %{glibcversion}
Release: 73%{?dist} Release: 74%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for # In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries. # libraries.
@ -731,6 +731,8 @@ Patch490: glibc-rh2222188-2.patch
Patch491: glibc-rh2222188-3.patch Patch491: glibc-rh2222188-3.patch
Patch492: glibc-rh2222188-4.patch Patch492: glibc-rh2222188-4.patch
Patch493: glibc-rh2222188-5.patch Patch493: glibc-rh2222188-5.patch
Patch494: glibc-rh2224289-1.patch
Patch495: glibc-rh2224289-2.patch
############################################################################## ##############################################################################
# Continued list of core "glibc" package information: # Continued list of core "glibc" package information:
@ -2888,6 +2890,9 @@ update_gconv_modules_cache ()
%endif %endif
%changelog %changelog
* Fri Jul 21 2023 Florian Weimer <fweimer@redhat.com> - 2.34-74
- rseq_area should always be 32 bytes large (#2224289)
* Thu Jul 20 2023 Florian Weimer <fweimer@redhat.com> - 2.34-73 * Thu Jul 20 2023 Florian Weimer <fweimer@redhat.com> - 2.34-73
- GCC Toolset 13 C++ compatibility for <math.h> iseqsig (#2222188) - GCC Toolset 13 C++ compatibility for <math.h> iseqsig (#2222188)