Home | History | Annotate | Download | only in seccomp-bpf

Lines Matching full:syscall

5 #include "sandbox/linux/seccomp-bpf/syscall.h"
13 #include <sys/syscall.h>
45 TEST(Syscall, InvalidCallReturnsENOSYS) {
46 EXPECT_EQ(-ENOSYS, Syscall::InvalidCall());
49 TEST(Syscall, WellKnownEntryPoint) {
50 // Test that Syscall::Call(-1) is handled specially. Don't do this on ARM,
51 // where syscall(-1) crashes with SIGILL. Not running the test is fine, as we
54 EXPECT_NE(Syscall::Call(-1), syscall(-1));
57 // If possible, test that Syscall::Call(-1) returns the address right
61 EXPECT_EQ(0x80CDu, ((uint16_t*)Syscall::Call(-1))[-1]); // INT 0x80
63 EXPECT_EQ(0x050Fu, ((uint16_t*)Syscall::Call(-1))[-1]); // SYSCALL
66 EXPECT_EQ(0xDF00u, ((uint16_t*)Syscall::Call(-1))[-1]); // SWI 0
68 EXPECT_EQ(0xEF000000u, ((uint32_t*)Syscall::Call(-1))[-1]); // SVC 0
72 EXPECT_EQ(0x0cu, (((uint32_t*)Syscall::Call(-1))[-1]) & 0x0000FFFF);
74 EXPECT_EQ(0xD4000001u, ((uint32_t*)Syscall::Call(-1))[-1]); // SVC 0
80 TEST(Syscall, TrivialSyscallNoArgs) {
82 EXPECT_EQ(Syscall::Call(__NR_getpid), syscall(__NR_getpid));
85 TEST(Syscall, TrivialSyscallOneArg) {
88 ASSERT_GE(new_fd = Syscall::Call(__NR_dup, 2), 0);
89 int close_return_value = IGNORE_EINTR(Syscall::Call(__NR_close, new_fd));
93 TEST(Syscall, TrivialFailingSyscall) {
95 int ret = Syscall::Call(__NR_dup, -1);
97 // Verify that Syscall::Call does not touch errno.
131 // We are testing Syscall::Call() by making use of a BPF filter that
134 BPF_TEST(Syscall,
150 BPF_ASSERT(Syscall::Call(__NR_uname,
172 TEST(Syscall, ComplexSyscallSixArgs) {
175 fd = Syscall::Call(__NR_openat, AT_FDCWD, "/dev/null", O_RDWR, 0L));
181 addr0 = reinterpret_cast<char*>(Syscall::Call(kMMapNr,
193 Syscall::Call(kMMapNr,
203 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr1, 4096L));
204 EXPECT_EQ(0, IGNORE_EINTR(Syscall::Call(__NR_close, fd)));
209 fd = Syscall::Call(__NR_openat, AT_FDCWD, "/proc/self/exe", O_RDONLY, 0L),
213 addr2 = reinterpret_cast<char*>(Syscall::Call(
216 addr3 = reinterpret_cast<char*>(Syscall::Call(kMMapNr,
233 EXPECT_EQ(8192, Syscall::Call(__NR_read, fd, buf, 8192L));
237 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr2, 8192L));
238 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr3, 4096L));
239 EXPECT_EQ(0, IGNORE_EINTR(Syscall::Call(__NR_close, fd)));