From nobody Mon Sep 28 21:02:06 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9804334DCE0; Mon, 17 Aug 2026 11:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786965452; cv=none; b=JlLEiG3pZQ49lcFdtR+9Y8+u4JSb4VfxVCnWZZbBQZpNxDgDo5StR6gP1JmZi5EvF9P6oeJp3Nlohour3Mzq9o+KkZiVL86KlxQgPEa3q25DgaaYFblR83e9l4Sd3pbgD7kGltTQxgCYIFcwKqIUVzLOx6PEkmVCOBBKdpwrUIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786965452; c=relaxed/simple; bh=JiLZMJoq4d69L4IH9eK1VMpFIEt1bTfHBBRtKsvQSJQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ipiFuWSMRO09QSBhLp1gQ3dBgjSNPOrsB4J1WS7A9ZFqot1Ki9w1VcKBRlNbhAhOS06PuAEQMtuTlXH8ZB86SWZs/BwTAZdZAvZrbw89uY2A8hcQJJo3NWzSFFSULW/zLeF7bcthiA+YzaC0S88a/qbKBfx0WZFH43JVCqxaNzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=BzvJ83lK; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="BzvJ83lK" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 237C5169C; Mon, 17 Aug 2026 04:17:26 -0700 (PDT) Received: from e127648.cambridge.arm.com (e127648.arm.com [10.1.39.91]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 87B863F66F; Mon, 17 Aug 2026 04:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1786965450; bh=JiLZMJoq4d69L4IH9eK1VMpFIEt1bTfHBBRtKsvQSJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BzvJ83lK2HNcMyBC+n2n4Zft0gSn0Amnn1C3Iyf2Qdxq/oeXl0paJwW/hSxc3TVMX oZcWUmPzogg4oVfvDLsIj4SMYEmgO1DHKnxT1eAYijkxdczMYg66FD3mTPVRcszxvF cB8zJcfXiRxDkO96u6UpLNGzqm9ITwg887zD/qtE= From: Christian Loehle To: Shuah Khan , linux-kselftest@vger.kernel.org Cc: Rama Krishna Katta , Thomas Gleixner , Gregory Price , Kees Cook , Peter Zijlstra , Andy Lutomirski , Gabriel Krisman Bertazi , linux-kernel@vger.kernel.org, Christian Loehle Subject: [PATCH 1/3] selftests/ptrace: Skip get_set_sud if SUD is unsupported Date: Mon, 17 Aug 2026 12:16:09 +0100 Message-Id: <1f16bf30aebbbf44ffc598359e0d474887162e7e.1786965107.git.christian.loehle@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 dispa= tch config api") Reported-by: Rama Krishna Katta Signed-off-by: Christian Loehle Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Gregory Price (Meta) --- 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/s= elftests/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 =3D 0; int status; =20 + ret =3D prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_OFF, + 0UL, 0UL, 0UL); + if (ret =3D=3D -1 && errno =3D=3D EINVAL) + SKIP(return, "Syscall User Dispatch is not supported"); + ASSERT_EQ(0, ret) { + TH_LOG("PR_SET_SYSCALL_USER_DISPATCH: %m"); + } + child =3D fork(); ASSERT_GE(child, 0); if (child =3D=3D 0) { --=20 2.34.1 From nobody Mon Sep 28 21:02:06 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C062340097A; Mon, 17 Aug 2026 11:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786965455; cv=none; b=qh72RrN0wXS+sqfeDO9nvkDs76Dgsx2/z5HEWsIevvvNkVxeYyJWW28Z//ZwOToia9MhvQ63CSsaBX046msWCR72jlG0+IpsmVlsUX311F/0CRINFxsscz4SUFEX5zV+ZbRBU4z0AEsFRAsHGX3OrL5g5DRg7f5CUrE9Up75heA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786965455; c=relaxed/simple; bh=RM0hGv+6VDkFzhjsai2QfAoQc61i/04uLEQEPH3o2kM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ptt1HmFGuifmzwrzGbpdL5KBip06jNlUeBXyJu4+xHWENopAs4336idlHYsuAIuQujM0h1um1RYGICUQBzCwh6XhxByuAkihIXNA0Met52pZA2biiV2oGzznE30eI29HQ3x+AznWvKfj7lLaX29pfmzMYIDZluxVreNy1Rpj88E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=vO+QXnta; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="vO+QXnta" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F7F716A3; Mon, 17 Aug 2026 04:17:29 -0700 (PDT) Received: from e127648.cambridge.arm.com (e127648.arm.com [10.1.39.91]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 75BE73F66F; Mon, 17 Aug 2026 04:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1786965453; bh=RM0hGv+6VDkFzhjsai2QfAoQc61i/04uLEQEPH3o2kM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vO+QXnta2AIsCG0VexgsU4FSMKnmCKx3wk7DDpuh4RP8xW9uf8381pl8s7S63ml2X TJknvGRB7b3Dlu9C01w/QLuNYb0nxsVHlvbpa8ibtve9eLnpolQPTTkd2JVBSRnEOc 6XwYCWZJjjPDjJR3Ye6GibZaPji2v6SHByT59l+w= From: Christian Loehle To: Shuah Khan , linux-kselftest@vger.kernel.org Cc: Rama Krishna Katta , Thomas Gleixner , Gregory Price , Kees Cook , Peter Zijlstra , Andy Lutomirski , Gabriel Krisman Bertazi , linux-kernel@vger.kernel.org, Christian Loehle Subject: [PATCH 2/3] selftests/syscall_user_dispatch: Skip tests if SUD is unsupported Date: Mon, 17 Aug 2026 12:16:10 +0100 Message-Id: <65c35ccbc7db2de2cb600439874e585775362580.1786965107.git.christian.loehle@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Gregory Price (Meta) --- .../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/too= ls/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) =3D SYSCALL_DISPATCH_FILTER_BLOCK) #define SYSCALL_DISPATCH_OFF(x) ((x) =3D SYSCALL_DISPATCH_FILTER_ALLOW) =20 +static bool require_sud(struct __test_metadata *_metadata) +{ + int ret; + + ret =3D prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_OFF, + 0UL, 0UL, 0UL); + if (ret =3D=3D -1 && errno =3D=3D 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; =20 + if (!require_sud(_metadata)) + return; + ret =3D sysinfo(&info); ASSERT_EQ(0, ret); =20 @@ -105,6 +123,9 @@ TEST(bad_prctl_param) char sel =3D SYSCALL_DISPATCH_FILTER_ALLOW; int op; =20 + if (!require_sud(_metadata)) + return; + /* Invalid op */ op =3D -1; prctl_invalid(_metadata, op, 0, 0, &sel, EINVAL); @@ -211,6 +232,9 @@ TEST(dispatch_and_return) { long ret; =20 + if (!require_sud(_metadata)) + return; + glob_sel =3D 0; nr_syscalls_emulated =3D 0; si_code =3D 0; @@ -259,6 +283,9 @@ TEST_SIGNAL(bad_selector, SIGSYS) sigset_t mask; struct sysinfo info; =20 + if (!require_sud(_metadata)) + return; + glob_sel =3D SYSCALL_DISPATCH_FILTER_ALLOW; nr_syscalls_emulated =3D 0; si_code =3D 0; @@ -301,6 +328,9 @@ TEST(disable_dispatch) struct sysinfo info; char sel =3D 0; =20 + if (!require_sud(_metadata)) + return; + ret =3D 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 =3D SYSCALL_DISPATCH_FILTER_ALLOW; =20 + 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 *_metadat= a, =20 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, fals= e); --=20 2.34.1 From nobody Mon Sep 28 21:02:06 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 446273F8247; Mon, 17 Aug 2026 11:17:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786965458; cv=none; b=Dk6P3EXdQW/doIROgGbRWbNUWRQoo+2jEtBaK4z0kwZEdrg8rszqaizkRCVGYKu6NAn7x24KvXxUPvkXp3TBBDv+xNHBEVNx0QBlqnQIGH4oqYjkGUQ6HMmFaJ0C6Y7P6PKlrrhYYjmb9+a8HQr2Lz4qf5OsEmjo/lROonoqrF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786965458; c=relaxed/simple; bh=ynL3bS6ayzq4sWttTuUIlly522D4dekptJwLpURqfMY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JGXYZQmd4qczYpUGIzBXiBqsgmGKmCUgZztX89TpMJd+gfhJRxtShYxHN1OThSdfMXrFg6wvw3x4bDKh3UhIceCAeWdyRfizV8NuL24vJchUVUYlstAjSm/pujy7idRkiVcEbgqGbvNYLzfLt+aWW/Y/HgwoYRK5TGOLWDKu2v0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=gywd3y2H; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="gywd3y2H" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BF1C71688; Mon, 17 Aug 2026 04:17:31 -0700 (PDT) Received: from e127648.cambridge.arm.com (e127648.arm.com [10.1.39.91]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6E2423F66F; Mon, 17 Aug 2026 04:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1786965455; bh=ynL3bS6ayzq4sWttTuUIlly522D4dekptJwLpURqfMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gywd3y2HVLoUciex3Lhznd/uByHZdwhcAwribYYRbl34XES4MtPWNdyIBtgXXhkyk HZ3Jeuv59WVIIrgRacngzFpurLH1KhhLtd4dSZbbS0FtVJASZkZIcep9gWxArPyd3K 8USVv9NIot7H7bdaVwzgQY0IpUx//c5YZNGW1hvc= From: Christian Loehle To: Shuah Khan , linux-kselftest@vger.kernel.org Cc: Rama Krishna Katta , Thomas Gleixner , Gregory Price , Kees Cook , Peter Zijlstra , Andy Lutomirski , Gabriel Krisman Bertazi , linux-kernel@vger.kernel.org, Christian Loehle Subject: [PATCH 3/3] selftests/syscall_user_dispatch: Skip benchmark if SUD is unsupported Date: Mon, 17 Aug 2026 12:16:11 +0100 Message-Id: <7f6caf7adeefaac0e57bb06d194b36795f2888bc.1786965107.git.christian.loehle@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Gregory Price (Meta) --- .../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 #include =20 +#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; =20 + ret =3D prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_OFF, + 0UL, 0UL, 0UL); + if (ret =3D=3D -1 && errno =3D=3D 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); =20 --=20 2.34.1