#include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
#include "sandbox/linux/seccomp-bpf/bpf_tests.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
-#include "sandbox/linux/services/android_futex.h"
+#include "sandbox/linux/seccomp-bpf/syscall.h"
#include "sandbox/linux/services/linux_syscalls.h"
#include "sandbox/linux/services/thread_helpers.h"
#include "sandbox/linux/tests/unit_tests.h"
BPF_DEATH_TEST_C(BaselinePolicy,
DisallowedCloneFlagCrashes,
- DEATH_MESSAGE(GetCloneErrorMessageContentForTests()),
+ DEATH_SEGV_MESSAGE(GetCloneErrorMessageContentForTests()),
BaselinePolicy) {
pid_t pid = syscall(__NR_clone, CLONE_THREAD | SIGCHLD);
HandlePostForkReturn(pid);
BPF_DEATH_TEST_C(BaselinePolicy,
DisallowedKillCrashes,
- DEATH_MESSAGE(GetKillErrorMessageContentForTests()),
+ DEATH_SEGV_MESSAGE(GetKillErrorMessageContentForTests()),
BaselinePolicy) {
BPF_ASSERT_NE(1, getpid());
kill(1, 0);
- _exit(1);
+ _exit(0);
}
BPF_TEST_C(BaselinePolicy, CanKillSelf, BaselinePolicy) {
#if defined(__x86_64__) || defined(__arm__)
BPF_DEATH_TEST_C(BaselinePolicy,
SocketpairWrongDomain,
- DEATH_MESSAGE(GetErrorMessageContentForTests()),
+ DEATH_SEGV_MESSAGE(GetErrorMessageContentForTests()),
BaselinePolicy) {
int sv[2];
ignore_result(socketpair(AF_INET, SOCK_STREAM, 0, sv));
BPF_ASSERT_EQ(EPERM, errno);
}
+BPF_DEATH_TEST_C(BaselinePolicy,
+ SIGSYS_InvalidSyscall,
+ DEATH_SEGV_MESSAGE(GetErrorMessageContentForTests()),
+ BaselinePolicy) {
+ Syscall::InvalidCall();
+}
+
// A failing test using this macro could be problematic since we perform
// system calls by passing "0" as every argument.
// The kernel could SIGSEGV the process or the system call itself could reboot
// the machine. Some thoughts have been given when hand-picking the system
// calls below to limit any potential side effects outside of the current
// process.
-#define TEST_BASELINE_SIGSYS(sysno) \
- BPF_DEATH_TEST_C(BaselinePolicy, \
- SIGSYS_##sysno, \
- DEATH_MESSAGE(GetErrorMessageContentForTests()), \
- BaselinePolicy) { \
- syscall(sysno, 0, 0, 0, 0, 0, 0); \
- _exit(1); \
+#define TEST_BASELINE_SIGSYS(sysno) \
+ BPF_DEATH_TEST_C(BaselinePolicy, \
+ SIGSYS_##sysno, \
+ DEATH_SEGV_MESSAGE(GetErrorMessageContentForTests()), \
+ BaselinePolicy) { \
+ syscall(sysno, 0, 0, 0, 0, 0, 0); \
+ _exit(1); \
}
TEST_BASELINE_SIGSYS(__NR_syslog);
BPF_DEATH_TEST_C(BaselinePolicy,
PrctlSigsys,
- DEATH_MESSAGE(GetPrctlErrorMessageContentForTests()),
+ DEATH_SEGV_MESSAGE(GetPrctlErrorMessageContentForTests()),
BaselinePolicy) {
prctl(PR_CAPBSET_READ, 0, 0, 0, 0);
_exit(1);