OSDN Git Service

selftests/seccomp: Check ENOSYS under tracing
authorKees Cook <keescook@chromium.org>
Sun, 5 Jul 2020 05:57:33 +0000 (22:57 -0700)
committerKees Cook <keescook@chromium.org>
Fri, 10 Jul 2020 23:01:52 +0000 (16:01 -0700)
There should be no difference between -1 and other negative syscalls
while tracing.

Cc: Keno Fischer <keno@juliacomputing.com>
Tested-by: Will Deacon <will@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
tools/testing/selftests/seccomp/seccomp_bpf.c

index 462a30e..13b88d5 100644 (file)
@@ -1942,6 +1942,26 @@ FIXTURE_TEARDOWN(TRACE_syscall)
        teardown_trace_fixture(_metadata, self->tracer);
 }
 
+TEST(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, negative_ENOSYS)
+{
+       negative_ENOSYS(_metadata);
+}
+
 TEST_F(TRACE_syscall, syscall_allowed)
 {
        /* getppid works as expected (no changes). */