aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/seccomp
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2020-07-04 22:57:33 -0700
committerKees Cook <keescook@chromium.org>2020-07-10 16:01:52 -0700
commit11eb004ef7ead0c43586adea0340b51da095bdee (patch)
tree75b81058740a418c30a274c26bf0f485f1de83dd /tools/testing/selftests/seccomp
parentselftests/seccomp: Refactor to use fixture variants (diff)
downloadlinux-dev-11eb004ef7ead0c43586adea0340b51da095bdee.tar.xz
linux-dev-11eb004ef7ead0c43586adea0340b51da095bdee.zip
selftests/seccomp: Check ENOSYS under tracing
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>
Diffstat (limited to 'tools/testing/selftests/seccomp')
-rw-r--r--tools/testing/selftests/seccomp/seccomp_bpf.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 462a30e81ca9..13b88d578db6 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -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). */