about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2023-07-21 16:18:18 +0200
committerArjun Shankar <arjun@redhat.com>2024-03-18 11:55:02 +0100
commitc9ee9cc8b8e4f8671c1d487f83db333b6be6a925 (patch)
tree0a37ef6ebf7c4df0a7c98d1a4183cd832cf40118
parent3cd02612e831500dacc8d731f23a52aae01cbc39 (diff)
downloadglibc-c9ee9cc8b8e4f8671c1d487f83db333b6be6a925.tar.gz
glibc-c9ee9cc8b8e4f8671c1d487f83db333b6be6a925.tar.xz
glibc-c9ee9cc8b8e4f8671c1d487f83db333b6be6a925.zip
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.

(cherry picked from commit 2c6b4b272e6b4d07303af25709051c3e96288f2d)
-rw-r--r--nptl/descr.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/nptl/descr.h b/nptl/descr.h
index e2627bce05..c6ff376a36 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -34,7 +34,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
@@ -408,14 +407,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