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