1# Copyright 2017 syzkaller project authors. All rights reserved. 2# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4include <sys/types.h> 5include <sys/mman.h> 6include <sys/stat.h> 7include <fcntl.h> 8include <unistd.h> 9include <sys/time.h> 10include <dirent.h> 11include <poll.h> 12include <sys/select.h> 13include <sys/param.h> 14include <sys/resource.h> 15include <time.h> 16include <signal.h> 17include <sys/wait.h> 18 19pipe(pipefd ptr[out, pipefd]) 20 21stat(file ptr[in, filename], statbuf ptr[out, stat]) 22lstat(file ptr[in, filename], statbuf ptr[out, stat]) 23 24poll(fds ptr[in, array[pollfd]], nfds len[fds], timeout int32) 25select(n len[inp], inp ptr[inout, fd_set], outp ptr[inout, fd_set], exp ptr[inout, fd_set], tvp ptr[inout, timeval]) 26 27mincore(addr vma, size len[addr], vec buffer[out]) 28 29fcntl$dupfd(fd fd, cmd flags[fcntl_dupfd], arg fd) fd 30fcntl$getflags(fd fd, cmd flags[fcntl_getflags]) 31fcntl$setflags(fd fd, cmd const[F_SETFD], flags flags[fcntl_flags]) 32fcntl$setstatus(fd fd, cmd const[F_SETFL], flags flags[fcntl_status]) 33fcntl$lock(fd fd, cmd flags[fcntl_lock], lock ptr[in, flock]) 34fcntl$getown(fd fd, cmd const[F_GETOWN]) pid 35fcntl$setown(fd fd, cmd const[F_SETOWN], pid pid) 36 37mknod(file ptr[in, filename], mode flags[mknod_mode], dev int32) 38mknod$loop(file ptr[in, filename], mode flags[mknod_mode], dev proc[1792, 2]) 39mknodat(dirfd fd_dir, file ptr[in, filename], mode flags[mknod_mode], dev int32) 40chmod(file ptr[in, filename], mode flags[open_mode]) 41fchmod(fd fd, mode flags[open_mode]) 42fchmodat(dirfd fd_dir, file ptr[in, filename], mode flags[open_mode], flags flags[at_flags]) 43chown(file ptr[in, filename], uid uid, gid gid) 44lchown(file ptr[in, filename], uid uid, gid gid) 45fchown(fd fd, uid uid, gid gid) 46fchownat(dirfd fd_dir, file ptr[in, filename], uid uid, gid gid, flags flags[at_flags]) 47faccessat(dirfd fd_dir, pathname ptr[in, filename], mode flags[open_mode], flags flags[faccessat_flags]) 48utimes(filename ptr[in, filename], times ptr[in, itimerval]) 49utimensat(dir fd_dir, pathname ptr[in, filename], times ptr[in, itimerval], flags flags[utimensat_flags]) 50 51execve(file ptr[in, filename], argv ptr[in, array[ptr[in, string]]], envp ptr[in, array[ptr[in, string]]]) 52 53getgid() gid 54getegid() gid 55setuid(uid uid) 56setgid(gid gid) 57seteuid(euid uid) 58setegid(egid gid) 59getuid() uid 60geteuid() uid 61setpgid(pid pid, pgid pid) 62getpgid(pid pid) pid 63getpgrp() pid 64getpid() pid 65getppid() pid 66setreuid(ruid uid, euid uid) 67setregid(rgid gid, egid gid) 68getgroups(size len[list], list ptr[inout, array[gid]]) 69setgroups(size len[list], list ptr[in, array[gid]]) 70 71link(old ptr[in, filename], new ptr[in, filename]) 72linkat(oldfd fd_dir, old ptr[in, filename], newfd fd_dir, new ptr[in, filename], flags flags[linkat_flags]) 73symlinkat(old ptr[in, filename], newfd fd_dir, new ptr[in, filename]) 74symlink(old ptr[in, filename], new ptr[in, filename]) 75unlink(path ptr[in, filename]) 76unlinkat(fd fd_dir, path ptr[in, filename], flags flags[unlinkat_flags]) 77readlink(path ptr[in, filename], buf buffer[out], siz len[buf]) 78readlinkat(fd fd_dir, path ptr[in, filename], buf buffer[out], siz len[buf]) 79rename(old ptr[in, filename], new ptr[in, filename]) 80renameat(oldfd fd_dir, old ptr[in, filename], newfd fd_dir, new ptr[in, filename]) 81mkdir(path ptr[in, filename], mode flags[open_mode]) 82mkdirat(fd fd_dir, path ptr[in, filename], mode flags[open_mode]) 83rmdir(path ptr[in, filename]) 84truncate(file ptr[in, filename], len intptr) 85ftruncate(fd fd, len intptr) 86flock(fd fd, op flags[flock_op]) 87fsync(fd fd) 88fdatasync(fd fd) 89sync() 90getdents(fd fd_dir, ent buffer[out], count len[ent]) 91chroot(dir ptr[in, filename]) 92fchroot(fd fd) 93chdir(dir ptr[in, filename]) 94fchdir(fd fd) 95 96getrusage(who flags[rusage_who], usage ptr[out, rusage]) 97getrlimit(res flags[rlimit_type], rlim ptr[out, rlimit]) 98setrlimit(res flags[rlimit_type], rlim ptr[in, rlimit]) 99 100clock_gettime(id flags[clock_id], tp ptr[out, timespec]) 101clock_settime(id flags[clock_id], tp ptr[in, timespec]) 102clock_getres(id flags[clock_id], tp ptr[out, timespec]) 103clock_nanosleep(id flags[clock_id], flags flags[timer_flags], rqtp ptr[in, timespec], rmtp ptr[out, timespec, opt]) 104nanosleep(req ptr[in, timespec], rem ptr[out, timespec, opt]) 105getitimer(which flags[getitimer_which], cur ptr[out, itimerval]) 106setitimer(which flags[getitimer_which], new ptr[in, itimerval], old ptr[out, itimerval, opt]) 107wait4(pid pid, status ptr[out, int32, opt], options flags[wait_options], ru ptr[out, rusage, opt]) 108 109pollfd { 110 fd fd 111 events flags[pollfd_events, int16] 112 revents const[0, int16] 113} 114 115timespec { 116 sec intptr 117 nsec intptr 118} 119 120timeval { 121 sec intptr 122 usec intptr 123} 124 125itimerval { 126 interv timeval 127 value timeval 128} 129 130# TODO: fd_set needs to be a separate type 131fd_set { 132 mask0 int64 133 mask1 int64 134 mask2 int64 135 mask3 int64 136 mask4 int64 137 mask5 int64 138 mask6 int64 139 mask7 int64 140} 141 142rusage { 143 utime timeval 144 stime timeval 145 maxrss intptr 146 ixrss intptr 147 idrss intptr 148 isrss intptr 149 minflt intptr 150 majflt intptr 151 nswap intptr 152 inblock intptr 153 oublock intptr 154 msgsnd intptr 155 msgrcv intptr 156 signals intptr 157 nvcsw intptr 158 nivcsw intptr 159} 160 161rlimit { 162 soft intptr 163 hard intptr 164} 165 166flock { 167 type flags[flock_type, int16] 168 whence flags[seek_whence, int16] 169 start intptr 170 len intptr 171 pid pid 172} 173 174linger { 175 onoff int32 176 linger int32 177} 178 179ucred { 180 pid pid 181 uid uid 182 gid gid 183} 184 185pollfd_events = POLLIN, POLLPRI, POLLOUT, POLLERR, POLLHUP, POLLNVAL, POLLRDNORM, POLLRDBAND, POLLWRNORM, POLLWRBAND 186mknod_mode = S_IFREG, S_IFCHR, S_IFBLK, S_IFIFO, S_IFSOCK, S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH 187at_flags = AT_SYMLINK_NOFOLLOW, AT_SYMLINK_FOLLOW 188linkat_flags = AT_SYMLINK_FOLLOW 189unlinkat_flags = 0, AT_REMOVEDIR 190flock_op = LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB 191faccessat_flags = AT_EACCESS, AT_SYMLINK_NOFOLLOW 192rusage_who = RUSAGE_SELF, RUSAGE_CHILDREN 193rlimit_type = RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_MEMLOCK, RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_STACK, RLIMIT_NTHR, RLIMIT_STACK 194clock_id = CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID, CLOCK_VIRTUAL, CLOCK_PROF 195getitimer_which = ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF, ITIMER_MONOTONIC 196wait_options = WALLSIG, WALTSIG, WCONTINUED, WEXITED, WNOHANG, WNOZOMBIE, WSTOPPED, WTRAPPED, WUNTRACED 197timer_flags = 0, TIMER_ABSTIME 198utimensat_flags = 0, AT_SYMLINK_NOFOLLOW 199fcntl_dupfd = F_DUPFD, F_DUPFD_CLOEXEC 200fcntl_getflags = F_GETFD, F_GETFL 201fcntl_lock = F_SETLK, F_SETLKW, F_GETLK 202fcntl_flags = FD_CLOEXEC 203fcntl_status = O_APPEND, O_ASYNC, O_NONBLOCK, O_DSYNC, O_RSYNC, O_ALT_IO, O_DIRECT, O_NOSIGPIPE 204flock_type = F_RDLCK, F_WRLCK, F_UNLCK 205