Skip to content

Commit 4c6614d

Browse files
keesshuahkh
authored andcommitted
selftests/seccomp: Check ENOSYS under tracing
There should be no difference between -1 and other negative syscalls while tracing. Cc: Andy Lutomirski <[email protected]> Cc: Will Drewry <[email protected]> Cc: Will Deacon <[email protected]> Cc: Keno Fischer <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 0bf18a0 commit 4c6614d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,32 @@ FIXTURE_TEARDOWN(TRACE_syscall)
19031903
teardown_trace_fixture(_metadata, self->tracer);
19041904
}
19051905

1906+
TEST(negative_ENOSYS)
1907+
{
1908+
/* Untraced negative syscalls should return ENOSYS. */
1909+
errno = 0;
1910+
EXPECT_EQ(-1, syscall(-1));
1911+
EXPECT_EQ(errno, ENOSYS);
1912+
errno = 0;
1913+
EXPECT_EQ(-1, syscall(-101));
1914+
EXPECT_EQ(errno, ENOSYS);
1915+
}
1916+
1917+
TEST_F(TRACE_syscall, negative_ENOSYS)
1918+
{
1919+
/*
1920+
* There should be no difference between an "internal" skip
1921+
* and userspace asking for syscall "-1".
1922+
*/
1923+
errno = 0;
1924+
EXPECT_EQ(-1, syscall(-1));
1925+
EXPECT_EQ(errno, ENOSYS);
1926+
/* And no difference for "still not valid but not -1". */
1927+
errno = 0;
1928+
EXPECT_EQ(-1, syscall(-101));
1929+
EXPECT_EQ(errno, ENOSYS);
1930+
}
1931+
19061932
TEST_F(TRACE_syscall, syscall_allowed)
19071933
{
19081934
/* getppid works as expected (no changes). */

0 commit comments

Comments
 (0)