diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-12-18 10:27:16 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-12-18 10:28:28 -0800 |
commit | 03226cd95055aee73d4e4dfcb4954490b4fd8a2d (patch) | |
tree | 8d7fad1c742f44825746e55f5f3c2ef8a9ee65b2 /test/syscalls/linux | |
parent | e7b47844d969673cec06ea745d577155131ecf3b (diff) |
Add BPFAction type with Stringer
PiperOrigin-RevId: 226018694
Change-Id: I98965e26fe565f37e98e5df5f997363ab273c91b
Diffstat (limited to 'test/syscalls/linux')
-rw-r--r-- | test/syscalls/linux/seccomp.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/syscalls/linux/seccomp.cc b/test/syscalls/linux/seccomp.cc index d6ac166a4..ac416b75f 100644 --- a/test/syscalls/linux/seccomp.cc +++ b/test/syscalls/linux/seccomp.cc @@ -215,6 +215,25 @@ TEST(SeccompTest, SeccompAppliesToVsyscall) { << "status " << status; } +TEST(SeccompTest, RetKillVsyscallCausesDeathBySIGSYS) { + SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(IsVsyscallEnabled())); + + pid_t const pid = fork(); + if (pid == 0) { + // Register a signal handler for SIGSYS that we don't expect to be invoked. + RegisterSignalHandler( + SIGSYS, +[](int, siginfo_t*, void*) { _exit(1); }); + ApplySeccompFilter(SYS_time, SECCOMP_RET_KILL); + vsyscall_time(nullptr); // Should result in death. + TEST_CHECK_MSG(false, "Survived invocation of test syscall"); + } + ASSERT_THAT(pid, SyscallSucceeds()); + int status; + ASSERT_THAT(waitpid(pid, &status, 0), SyscallSucceedsWithValue(pid)); + EXPECT_TRUE(WIFSIGNALED(status) && WTERMSIG(status) == SIGSYS) + << "status " << status; +} + TEST(SeccompTest, RetTraceWithoutPtracerReturnsENOSYS) { pid_t const pid = fork(); if (pid == 0) { |