1e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha/* seccomp_bpf_tests.c 2e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha * Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 3e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha * Use of this source code is governed by a BSD-style license that can be 4e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha * found in the LICENSE file. 5e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha * 6e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha * Test code for seccomp bpf. 7e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha */ 8e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 9e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <asm/siginfo.h> 10e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define __have_siginfo_t 1 11e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define __have_sigval_t 1 12e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define __have_sigevent_t 1 13e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 14e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <linux/filter.h> 15e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <linux/prctl.h> 16e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <linux/seccomp.h> 17e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <stddef.h> 18e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <stdbool.h> 19e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <string.h> 20e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <syscall.h> 21e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define __USE_GNU 1 22e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <sys/ucontext.h> 23e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include <sys/mman.h> 24e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 25e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#include "test_harness.h" 26e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 27e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#ifndef PR_SET_NO_NEW_PRIVS 28e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define PR_SET_NO_NEW_PRIVS 38 29e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define PR_GET_NO_NEW_PRIVS 39 30e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#endif 31e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 32e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#if defined(__i386__) 33e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_IP REG_EIP 34e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_SP REG_ESP 35e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_RESULT REG_EAX 36e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_SYSCALL REG_EAX 37e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG0 REG_EBX 38e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG1 REG_ECX 39e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG2 REG_EDX 40e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG3 REG_ESI 41e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG4 REG_EDI 42e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG5 REG_EBP 43e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#elif defined(__x86_64__) 44e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_IP REG_RIP 45e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_SP REG_RSP 46e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_RESULT REG_RAX 47e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_SYSCALL REG_RAX 48e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG0 REG_RDI 49e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG1 REG_RSI 50e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG2 REG_RDX 51e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG3 REG_R10 52e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG4 REG_R8 53e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#define REG_ARG5 REG_R9 54e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#endif 55e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 56e10f89421c169d4ab901d2853719375d74139ebdArun KulshreshthaFIXTURE_DATA(TRAP) { 57e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha struct sock_fprog prog; 58e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha}; 59e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 60e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha/* XXX: will need one per arch, etc. 61e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha * thankfully _arch can tell us the calling convention! 62e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha */ 63e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshthaextern void *thunk_ip; /* label for the instruction _after_ syscall */ 64e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshthastatic void syscall_thunk(void) 65e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha{ 66e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha asm("syscall; thunk_ip:"); 67e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha} 68e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 69e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshthastatic time_t vsyscall_time(time_t *p) 70e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha{ 71e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha register time_t t asm ("rax"); 72e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha register time_t *p1 asm ("rdi") = p; 73e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha __asm__("call 0xffffffffff600400 \n"); 74e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha return t; 75e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha} 76e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 77e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 78e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#if 0 79e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha/* For instance, we could jump here instead. */ 80e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshthastatic void compat_thunk(void) 81e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha{ 82e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha asm("int 0x80"); 83e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha} 84e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#endif 85e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 86e10f89421c169d4ab901d2853719375d74139ebdArun KulshreshthaFIXTURE_SETUP(TRAP) { 87e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* instruction after the syscall. Will be arch specific, of course. */ 88e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha unsigned long thunk_addr = (unsigned long)&thunk_ip; 89e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha TH_LOG("Thunk: 0x%lX\n", thunk_addr); 90e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha { 91e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha struct sock_filter filter[] = { 92e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 93e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha offsetof(struct seccomp_data, nr)), 94e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* Whitelist anything you might need in the sigaction */ 95e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#ifdef __NR_sigreturn 96e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_sigreturn, 3, 0), 97e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#endif 98e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_exit, 2, 0), 99e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_rt_sigreturn, 1, 0), 100e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* Allow __NR_write so easy logging. */ 101e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_write, 0, 1), 102e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), 103e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* Check if we're within the thunk. */ 104e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 105e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha offsetof(struct seccomp_data, instruction_pointer)), 106e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* XXX: make this 32-bit friendly. */ 107e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ((__u32*)&thunk_addr)[0], 0, 3), 108e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 109e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha offsetof(struct seccomp_data, instruction_pointer)+sizeof(int)), 110e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ((__u32*)&thunk_addr)[1], 0, 1), 111e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), 112e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_TRAP), 113e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha }; 114e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha memset(&self->prog, 0, sizeof(self->prog)); 115e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha self->prog.filter = malloc(sizeof(filter)); 116e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_NE(NULL, self->prog.filter); 117e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha memcpy(self->prog.filter, filter, sizeof(filter)); 118e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha self->prog.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])); 119e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha } 120e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha} 121e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 122e10f89421c169d4ab901d2853719375d74139ebdArun KulshreshthaFIXTURE_TEARDOWN(TRAP) { 123e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha if (self->prog.filter) 124e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha free(self->prog.filter); 125e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha}; 126e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 127e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshthastruct arch_sigsys { 128e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha void *_call_addr; /* calling user insn */ 129e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha int _syscall; /* triggering system call number */ 130e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha unsigned int _arch; /* AUDIT_ARCH_* of syscall */ 131e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha}; 132e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 133e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshthastatic void TRAP_action(int nr, siginfo_t *info, void *void_context) 134e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha{ 135e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ucontext_t *ctx = (ucontext_t *)void_context; 136e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha char buf[256]; 137e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha int len; 138e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha int do_ret = 1; 139e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha struct arch_sigsys *sys = (struct arch_sigsys *) 140e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#ifdef si_syscall 141e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha &(info->si_call_addr); 142e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#else 143e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha &(info->si_pid); 144e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha#endif 145e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 146e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha if (info->si_code != SYS_SECCOMP) 147e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha return; 148e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha if (!ctx) 149e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha return; 150e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha len = snprintf(buf, sizeof(buf), 151e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha "@0x%lX:%X:%d:0x%lX:0x%lX:0x%lX:0x%lX:0x%lX:0x%lX\n", 152e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha (unsigned long)sys->_call_addr, 153e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha sys->_arch, 154e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha sys->_syscall, 155e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_ARG0], 156e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_ARG1], 157e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_ARG2], 158e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_ARG3], 159e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_ARG4], 160e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_ARG5]); 161e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* Send the soft-fail to our "listener" */ 162e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha syscall(__NR_write, STDOUT_FILENO, buf, len); 163e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha if (ctx->uc_mcontext.gregs[REG_IP] >= 0xffffffffff600000ULL && 164e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_IP] < 0xffffffffff601000ULL) 165e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha do_ret = 0; 166e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha if (do_ret) { 167e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* push [REG_IP] */ 168e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_SP] -= sizeof(unsigned long); 169e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha *((unsigned long *)ctx->uc_mcontext.gregs[REG_SP]) = 170e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_IP]; 171e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha } 172e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* jmp syscall_thunk */ 173e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ctx->uc_mcontext.gregs[REG_IP] = (unsigned long)syscall_thunk; 174e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha return; 175e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha} 176e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 177e10f89421c169d4ab901d2853719375d74139ebdArun KulshreshthaTEST_F(TRAP, handler) { 178e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha int ret; 179e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha struct sigaction act; 180e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha pid_t pid; 181e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha sigset_t mask; 182e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha memset(&act, 0, sizeof(act)); 183e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha sigemptyset(&mask); 184e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha sigaddset(&mask, SIGSYS); 185e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 186e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha act.sa_sigaction = &TRAP_action; 187e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha act.sa_flags = SA_SIGINFO; 188e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ret = sigaction(SIGSYS, &act, NULL); 189e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_EQ(0, ret) { 190e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha TH_LOG("sigaction failed"); 191e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha } 192e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ret = sigprocmask(SIG_UNBLOCK, &mask, NULL); 193e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_EQ(0, ret) { 194e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha TH_LOG("sigprocmask failed"); 195e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha } 196e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 197e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* Get the pid to compare against. */ 198e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha pid = getpid(); 199e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 200e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); 201e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_EQ(0, ret); 202e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog); 203e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_EQ(0, ret); 204e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 205e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha /* Call anything! */ 206e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ret = syscall(__NR_getpid); 207e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_EQ(pid, ret); 208e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ret = syscall(__NR_close, 0); 209e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_EQ(0, ret); 210e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ret = syscall(__NR_close, 0); 211e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_EQ(-1, ret); 212e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha printf("The time is %ld\n", vsyscall_time(NULL)); 213e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha ASSERT_LT(0, vsyscall_time(NULL)); 214e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha} 215e10f89421c169d4ab901d2853719375d74139ebdArun Kulshreshtha 216e10f89421c169d4ab901d2853719375d74139ebdArun KulshreshthaTEST_HARNESS_MAIN 217