[PATCH] tests: Handle system-wide tunables in rseq tests

Michael Jeanson mjeanson@efficios.com
Tue Jun 30 18:51:30 GMT 2026


With the new system-wide tunables, a local policy could override the
rseq tunable set by the build system when running the tests. Add a check
in the tests for the expected state of the tunable and fail if it has
been overriden.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
---
 sysdeps/unix/sysv/linux/tst-rseq-disable.c | 12 ++++++++++++
 sysdeps/unix/sysv/linux/tst-rseq-nptl.c    |  2 ++
 sysdeps/unix/sysv/linux/tst-rseq.c         |  2 ++
 sysdeps/unix/sysv/linux/tst-rseq.h         |  7 +++++++
 4 files changed, 23 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/tst-rseq-disable.c b/sysdeps/unix/sysv/linux/tst-rseq-disable.c
index 7d66340eae..5ad32abbe3 100644
--- a/sysdeps/unix/sysv/linux/tst-rseq-disable.c
+++ b/sysdeps/unix/sysv/linux/tst-rseq-disable.c
@@ -105,6 +105,15 @@ check_rseq_disabled (void)
     }
 }
 
+static void
+check_rseq_tunable_disabled (void)
+{
+  /* Check that the environment properly sets the rseq tunable to disabled and
+     that it's not overriden by a system-wide policy.  */
+  if (rseq_tunable ())
+    FAIL_UNSUPPORTED ("glibc.pthread.rseq tunable forced to enabled, skipping test");
+}
+
 static void *
 thread_func (void *ignored)
 {
@@ -128,6 +137,9 @@ do_test (void)
           getauxval (AT_RSEQ_FEATURE_SIZE));
   printf ("info: getauxval (AT_RSEQ_ALIGN): %ld\n", getauxval (AT_RSEQ_ALIGN));
 
+  puts ("info: checking rseq tunable state");
+  check_rseq_tunable_disabled ();
+
   puts ("info: checking main thread");
   check_rseq_disabled ();
 
diff --git a/sysdeps/unix/sysv/linux/tst-rseq-nptl.c b/sysdeps/unix/sysv/linux/tst-rseq-nptl.c
index 02a5258afe..6031a99b7b 100644
--- a/sysdeps/unix/sysv/linux/tst-rseq-nptl.c
+++ b/sysdeps/unix/sysv/linux/tst-rseq-nptl.c
@@ -226,6 +226,8 @@ do_rseq_test (void)
   int t[] = { 1, 2, 6, 5, 4, 3, 50 };
   int i, result = 0;
 
+  if (!rseq_tunable ())
+    FAIL_UNSUPPORTED ("glibc.pthread.rseq tunable forced to disabled, skipping test");
   if (!rseq_available ())
     FAIL_UNSUPPORTED ("kernel does not support rseq, skipping test");
   setup_signals ();
diff --git a/sysdeps/unix/sysv/linux/tst-rseq.c b/sysdeps/unix/sysv/linux/tst-rseq.c
index ba93d390f4..a5c7c8aae6 100644
--- a/sysdeps/unix/sysv/linux/tst-rseq.c
+++ b/sysdeps/unix/sysv/linux/tst-rseq.c
@@ -110,6 +110,8 @@ proc_func (void *ignored)
 static int
 do_test (void)
 {
+  if (!rseq_tunable ())
+    FAIL_UNSUPPORTED ("glibc.pthread.rseq tunable forced to disabled, skipping test");
   if (!rseq_available ())
     {
       FAIL_UNSUPPORTED ("kernel does not support rseq, skipping test");
diff --git a/sysdeps/unix/sysv/linux/tst-rseq.h b/sysdeps/unix/sysv/linux/tst-rseq.h
index 1efa4f30f1..fd5220e40e 100644
--- a/sysdeps/unix/sysv/linux/tst-rseq.h
+++ b/sysdeps/unix/sysv/linux/tst-rseq.h
@@ -24,6 +24,7 @@
 #include <sys/rseq.h>
 #include <tls.h>
 #include <rseq-internal.h>
+#include <elf/dl-tunables.h>
 
 static inline bool
 rseq_thread_registered (void)
@@ -56,3 +57,9 @@ rseq_available (void)
       FAIL_EXIT1 ("Unexpected rseq error %s", strerror (errno));
     }
 }
+
+static inline bool
+rseq_tunable (void)
+{
+  return TUNABLE_GET_FULL (glibc, pthread, rseq, int, NULL);
+}
-- 
2.47.3



More information about the Libc-alpha mailing list