aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2020-07-04 23:12:32 -0700
committerShuah Khan <skhan@linuxfoundation.org>2020-07-17 13:37:34 -0600
commit4c6614dc86ad99208e7582108669831c4ab72982 (patch)
tree031d02dfa9e47d80195ba6cfddc6c5eaba1d4a09
parentselftests/seccomp: Refactor to use fixture variants (diff)
downloadlinux-dev-4c6614dc86ad99208e7582108669831c4ab72982.tar.xz
linux-dev-4c6614dc86ad99208e7582108669831c4ab72982.zip
selftests/seccomp: Check ENOSYS under tracing
There should be no difference between -1 and other negative syscalls while tracing. Cc: Andy Lutomirski <luto@amacapital.net> Cc: Will Drewry <wad@chromium.org> Cc: Will Deacon <will@kernel.org> Cc: Keno Fischer <keno@juliacomputing.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
-rw-r--r--tools/testing/selftests/seccomp/seccomp_bpf.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 0ade3b0f595a..ab52eb100c92 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -1903,6 +1903,32 @@ FIXTURE_TEARDOWN(TRACE_syscall)
teardown_trace_fixture(_metadata, self->tracer);
}
+TEST(negative_ENOSYS)
+{
+ /* Untraced negative syscalls should return ENOSYS. */
+ errno = 0;
+ EXPECT_EQ(-1, syscall(-1));
+ EXPECT_EQ(errno, ENOSYS);
+ errno = 0;
+ EXPECT_EQ(-1, syscall(-101));
+ EXPECT_EQ(errno, ENOSYS);
+}
+
+TEST_F(TRACE_syscall, negative_ENOSYS)
+{
+ /*
+ * There should be no difference between an "internal" skip
+ * and userspace asking for syscall "-1".
+ */
+ errno = 0;
+ EXPECT_EQ(-1, syscall(-1));
+ EXPECT_EQ(errno, ENOSYS);
+ /* And no difference for "still not valid but not -1". */
+ errno = 0;
+ EXPECT_EQ(-1, syscall(-101));
+ EXPECT_EQ(errno, ENOSYS);
+}
+
TEST_F(TRACE_syscall, syscall_allowed)
{
/* getppid works as expected (no changes). */