OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH vz10] selftests/rseq: skip syscall_errors_test when libc owns the registration
@ 2026-08-21 15:24 Eva Kurchatova
  2026-08-24 16:22 ` Konstantin Khorenko
  2026-08-24 16:32 ` [Devel] [PATCH vz10] ms/selftests/rseq: Don't run tests with runner scripts outside of the scripts Konstantin Khorenko
  0 siblings, 2 replies; 4+ messages in thread
From: Eva Kurchatova @ 2026-08-21 15:24 UTC (permalink / raw)


The test requires the calling thread to be unregistered and expects
EFAULT when registering an invalid address. glibc >= 2.35 registers
rseq for every thread at startup, so the kernel rejects the second
registration with EINVAL before it ever touches the address.

https://virtuozzo.atlassian.net/browse/VSTOR-139675
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/rseq/syscall_errors_test.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/rseq/syscall_errors_test.c b/tools/testing/selftests/rseq/syscall_errors_test.c
index a5d9e1f8a2dc..9e6bf6b1df96 100644
--- a/tools/testing/selftests/rseq/syscall_errors_test.c
+++ b/tools/testing/selftests/rseq/syscall_errors_test.c
@@ -34,6 +34,15 @@ int main(void)
 		goto error;
 	}
 
+	/*
+	 * The expectations below only hold for a thread which is not
+	 * registered, while glibc >= 2.35 registers every thread at startup.
+	 */
+	if (rseq_current_cpu_raw() >= 0) {
+		fprintf(stderr, "rseq is already registered, skipping\n");
+		return 4;
+	}
+
 	/* The current thread is NOT registered. */
 
 	/* EINVAL */
-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Devel] [PATCH vz10] selftests/rseq: skip syscall_errors_test when libc owns the registration
  2026-08-21 15:24 [Devel] [PATCH vz10] selftests/rseq: skip syscall_errors_test when libc owns the registration Eva Kurchatova
@ 2026-08-24 16:22 ` Konstantin Khorenko
  2026-08-24 16:32 ` [Devel] [PATCH vz10] ms/selftests/rseq: Don't run tests with runner scripts outside of the scripts Konstantin Khorenko
  1 sibling, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-08-24 16:22 UTC (permalink / raw)


nack.

After that we just get all tests SKIPPED,
while we should better unregister rseq and execute the test.

Mainstream has also fixed that but in different way - it prevents glibc registering rseq from the very beginning:
cb48828f06af ("selftests/rseq: Don't run tests with runner scripts outside of the scripts")

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 8/21/26 17:24, Eva Kurchatova wrote:
> The test requires the calling thread to be unregistered and expects
> EFAULT when registering an invalid address. glibc >= 2.35 registers
> rseq for every thread at startup, so the kernel rejects the second
> registration with EINVAL before it ever touches the address.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-139675
> Feature: fix selftests
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
> ---
>  tools/testing/selftests/rseq/syscall_errors_test.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/tools/testing/selftests/rseq/syscall_errors_test.c b/tools/testing/selftests/rseq/syscall_errors_test.c
> index a5d9e1f8a2dc..9e6bf6b1df96 100644
> --- a/tools/testing/selftests/rseq/syscall_errors_test.c
> +++ b/tools/testing/selftests/rseq/syscall_errors_test.c
> @@ -34,6 +34,15 @@ int main(void)
>  		goto error;
>  	}
>  
> +	/*
> +	 * The expectations below only hold for a thread which is not
> +	 * registered, while glibc >= 2.35 registers every thread at startup.
> +	 */
> +	if (rseq_current_cpu_raw() >= 0) {
> +		fprintf(stderr, "rseq is already registered, skipping\n");
> +		return 4;
> +	}
> +
>  	/* The current thread is NOT registered. */
>  
>  	/* EINVAL */


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Devel] [PATCH vz10] ms/selftests/rseq: Don't run tests with runner scripts outside of the scripts
  2026-08-21 15:24 [Devel] [PATCH vz10] selftests/rseq: skip syscall_errors_test when libc owns the registration Eva Kurchatova
  2026-08-24 16:22 ` Konstantin Khorenko
@ 2026-08-24 16:32 ` Konstantin Khorenko
  2026-08-24 16:32   ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
  1 sibling, 1 reply; 4+ messages in thread
From: Konstantin Khorenko @ 2026-08-24 16:32 UTC (permalink / raw)


From: Mark Brown <broonie@kernel.org>

The rseq selftests include two runner scripts run_param_test.sh and
run_syscall_errors_test.sh which set up the environment for test binaries
and run them with various parameters. Currently we list these test binaries
in TEST_GEN_PROGS but this results in the kselftest framework running them
directly as well as via the runners, resulting in duplication and spurious
failures when the environment is not correctly set up (eg, if glibc tries
to use rseq).

Move the binaries the runners invoke to TEST_GEN_PROGS_EXTENDED, binaries
listed there are built but not run by the framework.  The param_test
benchmarks are not moved since they are not run by run_param_test.sh.

Fixes: 830969e7821a ("selftests/rseq: Implement time slice extension test")

Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260423-selftests-rseq-use-runner-v1-1-e13a133754c1@kernel.org
Cc: stable@vger.kernel.org

(cherry picked from commit cb48828f06afa232cc330f0f4d6be101067810b3)

Conflict: slice_test does not exist in this tree, so it stays out of
TEST_GEN_PROGS.  Everything else matches the upstream commit.

Why the standalone binary was failing here.  The wrapper which sets the
environment up is already in the tree:

  GLIBC_TUNABLES="${GLIBC_TUNABLES:-}:glibc.pthread.rseq=0" ./syscall_errors_test

glibc.pthread.rseq=0 tells glibc not to register rseq, so the thread
really is unregistered and every expectation of the test holds.  No skip
inside the test is needed, it does its job for real.

What broke is that the binary was listed twice in effect: directly in
TEST_GEN_PROGS, and through the wrapper in TEST_PROGS.  emit_tests in
lib.mk writes out both, and the shipped rpm showed exactly that:

  rseq:param_test
  rseq:param_test_compare_twice
  rseq:param_test_mm_cid
  rseq:param_test_mm_cid_compare_twice
  rseq:syscall_errors_test          <- run directly, no tunable, fails
  rseq:run_param_test.sh
  rseq:run_syscall_errors_test.sh   <- run through the wrapper, passes

Our test runner walks that list entry by entry, so it invoked the bare
binary as well, and that one failed.  With this commit the duplicate
entries are gone and only the wrappers remain.

https://virtuozzo.atlassian.net/browse/VSTOR-139675
Feature: fix selftests
Reported-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/rseq/Makefile | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/rseq/Makefile b/tools/testing/selftests/rseq/Makefile
index 0d0a5fae5954..2cc472bac14e 100644
--- a/tools/testing/selftests/rseq/Makefile
+++ b/tools/testing/selftests/rseq/Makefile
@@ -14,12 +14,15 @@ LDLIBS += -lpthread -ldl
 # still track changes to header files and depend on shared object.
 OVERRIDE_TARGETS = 1
 
-TEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test param_test \
-		param_test_benchmark param_test_compare_twice param_test_mm_cid \
-		param_test_mm_cid_benchmark param_test_mm_cid_compare_twice \
-		syscall_errors_test
-
-TEST_GEN_PROGS_EXTENDED = librseq.so
+TEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test \
+		 param_test_benchmark param_test_mm_cid_benchmark
+
+TEST_GEN_PROGS_EXTENDED = librseq.so \
+	param_test \
+	param_test_compare_twice \
+	param_test_mm_cid \
+	param_test_mm_cid_compare_twice \
+	syscall_errors_test
 
 TEST_PROGS = run_param_test.sh run_syscall_errors_test.sh
 
-- 
2.47.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Devel] [PATCH RHEL10 COMMIT] ms/selftests/rseq: Don't run tests with runner scripts outside of the scripts
  2026-08-24 16:32 ` [Devel] [PATCH vz10] ms/selftests/rseq: Don't run tests with runner scripts outside of the scripts Konstantin Khorenko
@ 2026-08-24 16:32   ` Konstantin Khorenko
  0 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-08-24 16:32 UTC (permalink / raw)


The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.8.vz10
------>
commit b8ab001a0083d19b0fa5f9a7a0ea508fe19e51f4
Author: Mark Brown <broonie@kernel.org>
Date:   Thu Apr 23 20:17:45 2026 +0100

    ms/selftests/rseq: Don't run tests with runner scripts outside of the scripts
    
    The rseq selftests include two runner scripts run_param_test.sh and
    run_syscall_errors_test.sh which set up the environment for test binaries
    and run them with various parameters. Currently we list these test binaries
    in TEST_GEN_PROGS but this results in the kselftest framework running them
    directly as well as via the runners, resulting in duplication and spurious
    failures when the environment is not correctly set up (eg, if glibc tries
    to use rseq).
    
    Move the binaries the runners invoke to TEST_GEN_PROGS_EXTENDED, binaries
    listed there are built but not run by the framework.  The param_test
    benchmarks are not moved since they are not run by run_param_test.sh.
    
    Fixes: 830969e7821a ("selftests/rseq: Implement time slice extension test")
    
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Thomas Gleixner <tglx@kernel.org>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://patch.msgid.link/20260423-selftests-rseq-use-runner-v1-1-e13a133754c1 at kernel.org
    Cc: stable at vger.kernel.org
    
    (cherry picked from commit cb48828f06afa232cc330f0f4d6be101067810b3)
    
    Conflict: slice_test does not exist in this tree, so it stays out of
    TEST_GEN_PROGS.  Everything else matches the upstream commit.
    
    Why the standalone binary was failing here.  The wrapper which sets the
    environment up is already in the tree:
    
      GLIBC_TUNABLES="${GLIBC_TUNABLES:-}:glibc.pthread.rseq=0" ./syscall_errors_test
    
    glibc.pthread.rseq=0 tells glibc not to register rseq, so the thread
    really is unregistered and every expectation of the test holds.  No skip
    inside the test is needed, it does its job for real.
    
    What broke is that the binary was listed twice in effect: directly in
    TEST_GEN_PROGS, and through the wrapper in TEST_PROGS.  emit_tests in
    lib.mk writes out both, and the shipped rpm showed exactly that:
    
      rseq:param_test
      rseq:param_test_compare_twice
      rseq:param_test_mm_cid
      rseq:param_test_mm_cid_compare_twice
      rseq:syscall_errors_test          <- run directly, no tunable, fails
      rseq:run_param_test.sh
      rseq:run_syscall_errors_test.sh   <- run through the wrapper, passes
    
    Our test runner walks that list entry by entry, so it invoked the bare
    binary as well, and that one failed.  With this commit the duplicate
    entries are gone and only the wrappers remain.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-139675
    Feature: fix selftests
    Reported-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/rseq/Makefile | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/rseq/Makefile b/tools/testing/selftests/rseq/Makefile
index 0d0a5fae5954..2cc472bac14e 100644
--- a/tools/testing/selftests/rseq/Makefile
+++ b/tools/testing/selftests/rseq/Makefile
@@ -14,12 +14,15 @@ LDLIBS += -lpthread -ldl
 # still track changes to header files and depend on shared object.
 OVERRIDE_TARGETS = 1
 
-TEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test param_test \
-		param_test_benchmark param_test_compare_twice param_test_mm_cid \
-		param_test_mm_cid_benchmark param_test_mm_cid_compare_twice \
-		syscall_errors_test
-
-TEST_GEN_PROGS_EXTENDED = librseq.so
+TEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test \
+		 param_test_benchmark param_test_mm_cid_benchmark
+
+TEST_GEN_PROGS_EXTENDED = librseq.so \
+	param_test \
+	param_test_compare_twice \
+	param_test_mm_cid \
+	param_test_mm_cid_compare_twice \
+	syscall_errors_test
 
 TEST_PROGS = run_param_test.sh run_syscall_errors_test.sh
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-24 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-21 15:24 [Devel] [PATCH vz10] selftests/rseq: skip syscall_errors_test when libc owns the registration Eva Kurchatova
2026-08-24 16:22 ` Konstantin Khorenko
2026-08-24 16:32 ` [Devel] [PATCH vz10] ms/selftests/rseq: Don't run tests with runner scripts outside of the scripts Konstantin Khorenko
2026-08-24 16:32   ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox