* [LTP] [PATCH] syscall02: add invalid syscall number test
@ 2026-06-29 14:03 Andrea Cervesato
2026-06-29 14:53 ` [LTP] " linuxtestproject.agent
2026-06-30 0:29 ` [LTP] [PATCH] " Wei Gao via ltp
0 siblings, 2 replies; 6+ messages in thread
From: Andrea Cervesato @ 2026-06-29 14:03 UTC (permalink / raw)
To: Linux Test Project
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] syscall02: add invalid syscall number test
2026-06-29 14:03 [LTP] [PATCH] syscall02: add invalid syscall number test Andrea Cervesato
@ 2026-06-29 14:53 ` linuxtestproject.agent
2026-06-30 0:29 ` [LTP] [PATCH] " Wei Gao via ltp
1 sibling, 0 replies; 6+ messages in thread
From: linuxtestproject.agent @ 2026-06-29 14:53 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
On Mon, 29 Jun 2026, Andrea Cervesato wrote:
> syscall02: add invalid syscall number test
Verdict - Reviewed
---
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] syscall02: add invalid syscall number test
2026-06-29 14:03 [LTP] [PATCH] syscall02: add invalid syscall number test Andrea Cervesato
2026-06-29 14:53 ` [LTP] " linuxtestproject.agent
@ 2026-06-30 0:29 ` Wei Gao via ltp
2026-06-30 10:20 ` Petr Vorel
1 sibling, 1 reply; 6+ messages in thread
From: Wei Gao via ltp @ 2026-06-30 0:29 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
On Mon, Jun 29, 2026 at 04:03:09PM +0200, Andrea Cervesato wrote:
> 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),
> +};
I suggest add two more cases check:
1) -1
2) __NR_syscalls +1 (Base arch/powerpc/kernel/syscall.c)
> +
> +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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] syscall02: add invalid syscall number test
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
0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2026-06-30 10:20 UTC (permalink / raw)
To: Wei Gao; +Cc: Linux Test Project
Hi Andrea, Wei,
> > 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.
+1
Reviewed-by: Petr Vorel <pvorel@suse.cz>
...
> > +++ 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),
> > +};
> I suggest add two more cases check:
> 1) -1
> 2) __NR_syscalls +1 (Base arch/powerpc/kernel/syscall.c)
+1. Something like this wouldn't harm (tested only on x86_64 and x86).
Kind regards,
Petr
+++ testcases/kernel/syscalls/syscall/syscall02.c
@@ -14,12 +14,15 @@
* - below the architecture-specific private syscall ranges (e.g. ARM's
* 0x0f0000 base)
* - without the x32 ABI bit (0x40000000) set
+ * - -1
+ * - __NR_syscalls + 1
*
* Such a number is routed to sys_ni_syscall and returns ENOSYS.
*/
#include <unistd.h>
#include <sys/syscall.h>
+#include <asm-generic/unistd.h>
#include "tst_test.h"
@@ -32,6 +35,8 @@ static struct tcase {
TC(0x8000),
TC(0xf000),
TC(0xfffe),
+ TC(-1),
+ TC(__NR_syscalls + 1),
};
static void verify_syscall(unsigned int n)
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] syscall02: add invalid syscall number test
2026-06-30 10:20 ` Petr Vorel
@ 2026-06-30 10:57 ` Andrea Cervesato via ltp
2026-06-30 16:40 ` Petr Vorel
0 siblings, 1 reply; 6+ messages in thread
From: Andrea Cervesato via ltp @ 2026-06-30 10:57 UTC (permalink / raw)
To: Petr Vorel; +Cc: Linux Test Project
Hi Petr,
> > I suggest add two more cases check:
> > 1) -1
> > 2) __NR_syscalls +1 (Base arch/powerpc/kernel/syscall.c)
>
that was my initial idea, but different architectures are starting
from a different value and I wanted to make it generic. I guess
the right way would be to include syscalls.h and use
__LTP__NR_INVALID_SYSCALL at this point. WDYT?
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] syscall02: add invalid syscall number test
2026-06-30 10:57 ` Andrea Cervesato via ltp
@ 2026-06-30 16:40 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2026-06-30 16:40 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Hi Andrea,
> Hi Petr,
> > > I suggest add two more cases check:
> > > 1) -1
> > > 2) __NR_syscalls +1 (Base arch/powerpc/kernel/syscall.c)
> that was my initial idea, but different architectures are starting
> from a different value and I wanted to make it generic. I guess
> the right way would be to include syscalls.h and use
> __LTP__NR_INVALID_SYSCALL at this point. WDYT?
Yes, __LTP__NR_INVALID_SYSCALL is better than -1 (for all archs we have
#define __LTP__NR_INVALID_SYSCALL -1)
But I'd also use __NR_syscalls from <asm-generic/unistd.h> (the second suggested
case), i.e. have arch dependent value based on UAPI headers.
Also, you could add a real description to the values to .desc.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-30 16:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 14:03 [LTP] [PATCH] syscall02: add invalid syscall number test Andrea Cervesato
2026-06-29 14:53 ` [LTP] " 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox