Skip to content

Commit 11eb004

Browse files
committed
selftests/seccomp: Check ENOSYS under tracing
There should be no difference between -1 and other negative syscalls while tracing. Cc: Keno Fischer <[email protected]> Tested-by: Will Deacon <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent adeeec8 commit 11eb004

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,26 @@ FIXTURE_TEARDOWN(TRACE_syscall)
19421942
teardown_trace_fixture(_metadata, self->tracer);
19431943
}
19441944

1945+
TEST(negative_ENOSYS)
1946+
{
1947+
/*
1948+
* There should be no difference between an "internal" skip
1949+
* and userspace asking for syscall "-1".
1950+
*/
1951+
errno = 0;
1952+
EXPECT_EQ(-1, syscall(-1));
1953+
EXPECT_EQ(errno, ENOSYS);
1954+
/* And no difference for "still not valid but not -1". */
1955+
errno = 0;
1956+
EXPECT_EQ(-1, syscall(-101));
1957+
EXPECT_EQ(errno, ENOSYS);
1958+
}
1959+
1960+
TEST_F(TRACE_syscall, negative_ENOSYS)
1961+
{
1962+
negative_ENOSYS(_metadata);
1963+
}
1964+
19451965
TEST_F(TRACE_syscall, syscall_allowed)
19461966
{
19471967
/* getppid works as expected (no changes). */

0 commit comments

Comments
 (0)