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