The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/3] selftests: Skip SUD tests when unsupported
@ 2026-08-17 11:16 Christian Loehle
  2026-08-17 11:16 ` [PATCH 1/3] selftests/ptrace: Skip get_set_sud if SUD is unsupported Christian Loehle
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christian Loehle @ 2026-08-17 11:16 UTC (permalink / raw)
  To: Shuah Khan, linux-kselftest
  Cc: Rama Krishna Katta, Thomas Gleixner, Gregory Price, Kees Cook,
	Peter Zijlstra, Andy Lutomirski, Gabriel Krisman Bertazi,
	linux-kernel, Christian Loehle

Syscall User Dispatch (SUD) is unavailable on architectures without
generic syscall entry. Such architectures return -EINVAL for otherwise
valid SUD prctl and ptrace requests, which the SUD selftests currently
report as failures.

Probe SUD with a valid disabled configuration and skip the affected tests
when that probe returns EINVAL. Unexpected errors remain failures, and the
existing coverage is unchanged on kernels that support SUD.

Christian Loehle (3):
  selftests/ptrace: Skip get_set_sud if SUD is unsupported
  selftests/syscall_user_dispatch: Skip tests if SUD is unsupported
  selftests/syscall_user_dispatch: Skip benchmark if SUD is unsupported

 tools/testing/selftests/ptrace/get_set_sud.c  |  8 +++++
 .../syscall_user_dispatch/sud_benchmark.c     |  9 +++++
 .../syscall_user_dispatch/sud_test.c          | 36 +++++++++++++++++++
 3 files changed, 53 insertions(+)


base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
-- 
2.34.1

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

* [PATCH 1/3] selftests/ptrace: Skip get_set_sud if SUD is unsupported
  2026-08-17 11:16 [PATCH 0/3] selftests: Skip SUD tests when unsupported Christian Loehle
@ 2026-08-17 11:16 ` Christian Loehle
  2026-08-17 11:16 ` [PATCH 2/3] selftests/syscall_user_dispatch: Skip tests " Christian Loehle
  2026-08-17 11:16 ` [PATCH 3/3] selftests/syscall_user_dispatch: Skip benchmark " Christian Loehle
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Loehle @ 2026-08-17 11:16 UTC (permalink / raw)
  To: Shuah Khan, linux-kselftest
  Cc: Rama Krishna Katta, Thomas Gleixner, Gregory Price, Kees Cook,
	Peter Zijlstra, Andy Lutomirski, Gabriel Krisman Bertazi,
	linux-kernel, Christian Loehle

Syscall User Dispatch is unavailable on architectures without generic
syscall entry. Such architectures return -EINVAL for otherwise valid SUD
ptrace requests.

The test currently treats this as a failure even though the feature is
not supported. Probe SUD with a valid disabled configuration before
creating the tracee and skip the test when the kernel returns EINVAL.
Other errors remain test failures, and kernels that support SUD continue
to exercise the ptrace GET/SET requests.

Fixes: 8c8fa605f7b8 ("selftest, ptrace: Add selftest for syscall user dispatch config api")
Reported-by: Rama Krishna Katta <ramakrishna.katta@arm.com>
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
 tools/testing/selftests/ptrace/get_set_sud.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/testing/selftests/ptrace/get_set_sud.c b/tools/testing/selftests/ptrace/get_set_sud.c
index 2e619c7599bb..395674f85964 100644
--- a/tools/testing/selftests/ptrace/get_set_sud.c
+++ b/tools/testing/selftests/ptrace/get_set_sud.c
@@ -22,6 +22,14 @@ TEST(get_set_sud)
 	int ret = 0;
 	int status;
 
+	ret = prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_OFF,
+		    0UL, 0UL, 0UL);
+	if (ret == -1 && errno == EINVAL)
+		SKIP(return, "Syscall User Dispatch is not supported");
+	ASSERT_EQ(0, ret) {
+		TH_LOG("PR_SET_SYSCALL_USER_DISPATCH: %m");
+	}
+
 	child = fork();
 	ASSERT_GE(child, 0);
 	if (child == 0) {
-- 
2.34.1


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

* [PATCH 2/3] selftests/syscall_user_dispatch: Skip tests if SUD is unsupported
  2026-08-17 11:16 [PATCH 0/3] selftests: Skip SUD tests when unsupported Christian Loehle
  2026-08-17 11:16 ` [PATCH 1/3] selftests/ptrace: Skip get_set_sud if SUD is unsupported Christian Loehle
@ 2026-08-17 11:16 ` Christian Loehle
  2026-08-17 11:16 ` [PATCH 3/3] selftests/syscall_user_dispatch: Skip benchmark " Christian Loehle
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Loehle @ 2026-08-17 11:16 UTC (permalink / raw)
  To: Shuah Khan, linux-kselftest
  Cc: Rama Krishna Katta, Thomas Gleixner, Gregory Price, Kees Cook,
	Peter Zijlstra, Andy Lutomirski, Gabriel Krisman Bertazi,
	linux-kernel, Christian Loehle

Syscall User Dispatch is unavailable on architectures without generic
syscall entry. Such architectures return -EINVAL for otherwise valid SUD
prctl requests, causing sud_test to report failures.

This also prevents bad_prctl_param from providing useful coverage. The
unsupported stub returns EINVAL before argument validation, so valid
operations fail and requests expected to fail with EFAULT return EINVAL.

Probe SUD with a valid disabled configuration at the start of each test
and skip when the kernel returns EINVAL. Preserve failures for unexpected
errors and continue to run the full test on supported kernels.

Fixes: 179ef035992e ("selftests: Add kselftest for syscall user dispatch")
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
 .../syscall_user_dispatch/sud_test.c          | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_test.c b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
index b855c6000287..1c84b86e24ba 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_test.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
@@ -41,6 +41,21 @@
 #define SYSCALL_DISPATCH_ON(x) ((x) = SYSCALL_DISPATCH_FILTER_BLOCK)
 #define SYSCALL_DISPATCH_OFF(x) ((x) = SYSCALL_DISPATCH_FILTER_ALLOW)
 
+static bool require_sud(struct __test_metadata *_metadata)
+{
+	int ret;
+
+	ret = prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_OFF,
+		    0UL, 0UL, 0UL);
+	if (ret == -1 && errno == EINVAL)
+		SKIP(return false, "Syscall User Dispatch is not supported");
+	ASSERT_EQ(0, ret) {
+		TH_LOG("PR_SET_SYSCALL_USER_DISPATCH: %m");
+	}
+
+	return true;
+}
+
 /* Test Summary:
  *
  * - dispatch_trigger_sigsys: Verify if PR_SET_SYSCALL_USER_DISPATCH is
@@ -68,6 +83,9 @@ TEST_SIGNAL(dispatch_trigger_sigsys, SIGSYS)
 	struct sysinfo info;
 	int ret;
 
+	if (!require_sud(_metadata))
+		return;
+
 	ret = sysinfo(&info);
 	ASSERT_EQ(0, ret);
 
@@ -105,6 +123,9 @@ TEST(bad_prctl_param)
 	char sel = SYSCALL_DISPATCH_FILTER_ALLOW;
 	int op;
 
+	if (!require_sud(_metadata))
+		return;
+
 	/* Invalid op */
 	op = -1;
 	prctl_invalid(_metadata, op, 0, 0, &sel, EINVAL);
@@ -211,6 +232,9 @@ TEST(dispatch_and_return)
 {
 	long ret;
 
+	if (!require_sud(_metadata))
+		return;
+
 	glob_sel = 0;
 	nr_syscalls_emulated = 0;
 	si_code = 0;
@@ -259,6 +283,9 @@ TEST_SIGNAL(bad_selector, SIGSYS)
 	sigset_t mask;
 	struct sysinfo info;
 
+	if (!require_sud(_metadata))
+		return;
+
 	glob_sel = SYSCALL_DISPATCH_FILTER_ALLOW;
 	nr_syscalls_emulated = 0;
 	si_code = 0;
@@ -301,6 +328,9 @@ TEST(disable_dispatch)
 	struct sysinfo info;
 	char sel = 0;
 
+	if (!require_sud(_metadata))
+		return;
+
 	ret = prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_EXCLUSIVE_ON, 0, 0, &sel);
 	ASSERT_EQ(0, ret) {
 		TH_LOG("Kernel does not support CONFIG_SYSCALL_USER_DISPATCH");
@@ -329,6 +359,9 @@ TEST(direct_dispatch_range)
 	struct sysinfo info;
 	char sel = SYSCALL_DISPATCH_FILTER_ALLOW;
 
+	if (!require_sud(_metadata))
+		return;
+
 	/*
 	 * Instead of calculating libc addresses; allow the entire
 	 * memory map and lock the selector.
@@ -365,6 +398,9 @@ static void test_range(struct __test_metadata *_metadata,
 
 TEST(dispatch_range)
 {
+	if (!require_sud(_metadata))
+		return;
+
 	ASSERT_EQ(0, setup_sigsys_handler());
 	test_range(_metadata, PR_SYS_DISPATCH_EXCLUSIVE_ON, 0, 0, true);
 	test_range(_metadata, PR_SYS_DISPATCH_EXCLUSIVE_ON, syscall_addr, 1, false);
-- 
2.34.1


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

* [PATCH 3/3] selftests/syscall_user_dispatch: Skip benchmark if SUD is unsupported
  2026-08-17 11:16 [PATCH 0/3] selftests: Skip SUD tests when unsupported Christian Loehle
  2026-08-17 11:16 ` [PATCH 1/3] selftests/ptrace: Skip get_set_sud if SUD is unsupported Christian Loehle
  2026-08-17 11:16 ` [PATCH 2/3] selftests/syscall_user_dispatch: Skip tests " Christian Loehle
@ 2026-08-17 11:16 ` Christian Loehle
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Loehle @ 2026-08-17 11:16 UTC (permalink / raw)
  To: Shuah Khan, linux-kselftest
  Cc: Rama Krishna Katta, Thomas Gleixner, Gregory Price, Kees Cook,
	Peter Zijlstra, Andy Lutomirski, Gabriel Krisman Bertazi,
	linux-kernel, Christian Loehle

Syscall User Dispatch is unavailable on architectures without generic
syscall entry. On such architectures, sud_benchmark spends several
seconds calibrating before its SUD prctl fails with EINVAL.

Probe SUD with a valid disabled configuration before calibration and skip
when the kernel returns EINVAL. Treat other probe errors as failures and
continue to run the benchmark unchanged on supported kernels.

Fixes: d87ae0fa21c2 ("selftests: Add benchmark for syscall user dispatch")
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
 .../selftests/syscall_user_dispatch/sud_benchmark.c      | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
index 073a03702ff5..bb05fece301a 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
@@ -18,6 +18,8 @@
 #include <sys/prctl.h>
 #include <sys/syscall.h>
 
+#include "kselftest.h"
+
 #ifndef PR_SET_SYSCALL_USER_DISPATCH
 # define PR_SET_SYSCALL_USER_DISPATCH	59
 # define PR_SYS_DISPATCH_OFF	0
@@ -140,6 +142,13 @@ int main(void)
 	int ret;
 	sigset_t mask;
 
+	ret = prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_OFF,
+		    0UL, 0UL, 0UL);
+	if (ret == -1 && errno == EINVAL)
+		ksft_exit_skip("Syscall User Dispatch is not supported\n");
+	if (ret)
+		ksft_exit_fail_perror("PR_SET_SYSCALL_USER_DISPATCH");
+
 	memset(&act, 0, sizeof(act));
 	sigemptyset(&mask);
 
-- 
2.34.1


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

end of thread, other threads:[~2026-08-17 11:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17 11:16 [PATCH 0/3] selftests: Skip SUD tests when unsupported Christian Loehle
2026-08-17 11:16 ` [PATCH 1/3] selftests/ptrace: Skip get_set_sud if SUD is unsupported Christian Loehle
2026-08-17 11:16 ` [PATCH 2/3] selftests/syscall_user_dispatch: Skip tests " Christian Loehle
2026-08-17 11:16 ` [PATCH 3/3] selftests/syscall_user_dispatch: Skip benchmark " Christian Loehle

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