Linux Test Project
 help / color / mirror / Atom feed
From: Andrea Cervesato <andrea.cervesato@suse.de>
To: Linux Test Project <ltp@lists.linux.it>
Subject: [LTP] [PATCH] syscall02: add invalid syscall number test
Date: Mon, 29 Jun 2026 16:03:09 +0200	[thread overview]
Message-ID: <20260629-invalid_syscalls-v1-1-6276034a35c5@suse.com> (raw)

From: Andrea Cervesato <andrea.cervesato@suse.com>

Add a test verifying that syscall() returns ENOSYS when called with
unimplemented syscall numbers. The chosen numbers stay above the syscall
table and below the architecture-specific private ranges, so they are
reliably invalid on every supported architecture.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 runtest/syscalls                              |  1 +
 testcases/kernel/syscalls/syscall/.gitignore  |  1 +
 testcases/kernel/syscalls/syscall/syscall02.c | 47 +++++++++++++++++++++++++++
 3 files changed, 49 insertions(+)

diff --git a/runtest/syscalls b/runtest/syscalls
index a021c79da49d4157c33187caed2dd3f0483759e0..8a777e61da1af59ba694e0bc5b5d92bb1d63754a 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1678,6 +1678,7 @@ sync_file_range01 sync_file_range01
 sync_file_range02 sync_file_range02
 
 syscall01 syscall01
+syscall02 syscall02
 
 sysconf01 sysconf01
 
diff --git a/testcases/kernel/syscalls/syscall/.gitignore b/testcases/kernel/syscalls/syscall/.gitignore
index 74a081e40cb564e874e0f81478d3d1a0e95b6df4..fed1d81079450a7442023447285cd112924f7a10 100644
--- a/testcases/kernel/syscalls/syscall/.gitignore
+++ b/testcases/kernel/syscalls/syscall/.gitignore
@@ -1 +1,2 @@
 /syscall01
+/syscall02
diff --git a/testcases/kernel/syscalls/syscall/syscall02.c b/testcases/kernel/syscalls/syscall/syscall02.c
new file mode 100644
index 0000000000000000000000000000000000000000..3bd9fa8cdcca257e03b358749ee7a2b676d8720d
--- /dev/null
+++ b/testcases/kernel/syscalls/syscall/syscall02.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify that :manpage:`syscall(2)` fails with ENOSYS when invoked with
+ * invalid syscall numbers.
+ *
+ * The syscall number is dispatched as an unsigned value on Linux. A value is
+ * reliably unimplemented on every supported architecture when it is:
+ *
+ * - above the syscall table
+ * - below the architecture-specific private syscall ranges (e.g. ARM's
+ *   0x0f0000 base)
+ * - without the x32 ABI bit (0x40000000) set
+ *
+ * Such a number is routed to sys_ni_syscall and returns ENOSYS.
+ */
+
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "tst_test.h"
+
+#define TC(x) {.scno = (long)(x), .desc = #x}
+
+static struct tcase {
+	long scno;
+	const char *desc;
+} tcases[] = {
+	TC(0x8000),
+	TC(0xf000),
+	TC(0xfffe),
+};
+
+static void verify_syscall(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TST_EXP_FAIL2(syscall(tc->scno), ENOSYS, "syscall(%s)", tc->desc);
+}
+
+static struct tst_test test = {
+	.test = verify_syscall,
+	.tcnt = ARRAY_SIZE(tcases),
+};

---
base-commit: ad68429b9cfd55b233733e45e600ffafa1458ac5
change-id: 20260629-invalid_syscalls-0476c52d7d0c

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2026-06-29 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 14:03 Andrea Cervesato [this message]
2026-06-29 14:53 ` [LTP] syscall02: add invalid syscall number test linuxtestproject.agent
2026-06-30  0:29 ` [LTP] [PATCH] " Wei Gao via ltp
2026-06-30 10:20   ` Petr Vorel
2026-06-30 10:57     ` Andrea Cervesato via ltp
2026-06-30 16:40       ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260629-invalid_syscalls-v1-1-6276034a35c5@suse.com \
    --to=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox