Skip to contentSkip to conversation

syscall02: test invalid syscall number -1

PATCH Superseded Andrea Cervesato 2 participants 2 messages Jul 14

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscall02: test invalid syscall number -1

From: Andrea Cervesato <[email protected]>

Add a test verifying that a raw syscall() with the reserved number -1 fails with ENOSYS. The behavior is architecture specific, so the test is limited to the architectures where it was checked against kernel code.

---
 runtest/syscalls                              |  1 +
 testcases/kernel/syscalls/syscall/.gitignore  |  1 +
 testcases/kernel/syscalls/syscall/syscall02.c | 32 +++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
runtest/syscalls +1 -0
index a021c79da49d4157c33187caed2dd3f0483759e0..8a777e61da1af59ba694e0bc5b5d92bb1d63754a 100644
@@ -1678,6 +1678,7 @@ sync_file_range01 sync_file_range01
 sync_file_range02 sync_file_range02
 
 syscall01 syscall01
+syscall02 syscall02
 
 sysconf01 sysconf01
 
testcases/kernel/syscalls/syscall/.gitignore +1 -0
index 74a081e40cb564e874e0f81478d3d1a0e95b6df4..fed1d81079450a7442023447285cd112924f7a10 100644
@@ -1 +1,2 @@
 /syscall01
+/syscall02
testcases/kernel/syscalls/syscall/syscall02.c new file +32 -0
new file mode 100644
index 0000000000000000000000000000000000000000..579b455ac00578a41a629ebeba478f55a3b161d6
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+/*\
+ * Verify that a raw :manpage:`syscall(2)` with the reserved system call
+ * number -1 fails with ENOSYS.
+ *
+ * The behavior of number -1 is architecture specific, so the test only runs on
+ * the architectures where it has been verified against the kernel entry code.
+ */
+
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "tst_test.h"
+
+static void run(void)
+{
+	TST_EXP_FAIL2(syscall(-1), ENOSYS, "invalid syscall number -1");
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.supported_archs = (const char *const []) {
+		"x86_64",
+		"aarch64",
+		NULL
+	},
+};

---
base-commit: 7ca5dc366a558f3666223e6abe579edd90bafd38
change-id: 20260714-syscall_invalid_nr-cf61f64f2741

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Andrea,

testcases/kernel/syscalls/syscall/syscall02.c line 16

Quoted 4 lines · Andrea Cervesato

syscall02: test invalid syscall number -1

testcases/kernel/syscalls/syscall/syscall02.c new file +2 -0
+#include <unistd.h>
+#include <sys/syscall.h>

<sys/syscall.h> provides SYS_* constants, but none are used here. syscall() is declared by <unistd.h>. The include can be dropped.

Quoted 2 lines

+ * Verify that a raw :manpage:syscall(2) with the reserved system call
+ * number -1 fails with ENOSYS.

Same in the commit message body: -1 is not formally reserved by the kernel ABI or POSIX. It is simply an out-of-range number that lands on sys_ni_syscall. The test itself uses "invalid" in the message string, which is the more accurate term. Worth aligning the description with that wording.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp