| # Copyright 2017 syzkaller project authors. All rights reserved. |
| # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. |
| |
| include <sys/mman.h> |
| include <sys/types.h> |
| include <sys/wait.h> |
| include <sys/stat.h> |
| include <fcntl.h> |
| include <unistd.h> |
| |
| resource fd[int32]: 0xffffffffffffffff, AT_FDCWD |
| resource pid[int32]: 0, 0xffffffffffffffff |
| |
| openat(fd fd, file ptr[in, filename], flags flags[open_flags], mode flags[open_mode]) fd |
| read(fd fd, buf buffer[out], count len[buf]) |
| write(fd fd, buf buffer[in], count len[buf]) |
| close(fd fd) |
| abort_sysc_fd(fd fd) |
| stat(file ptr[in, filename], statbuf ptr[out, array[int8]]) |
| fstat(fd fd, statbuf ptr[out, array[int8]]) |
| lstat(file ptr[in, filename], statbuf ptr[out, array[int8]]) |
| llseek(fd fd, offset_hi intptr, offset_lo intptr, result ptr[out, int64], whence flags[seek_whence]) |
| link(old ptr[in, filename], new ptr[in, filename]) |
| unlink(path ptr[in, filename]) |
| symlink(old ptr[in, filename], new ptr[in, filename]) |
| readlink(path ptr[in, filename], buf buffer[out], siz len[buf]) |
| chdir(dir ptr[in, filename]) |
| fchdir(fd fd) |
| getcwd(buf buffer[out], size len[buf]) |
| rename(old ptr[in, filename], new ptr[in, filename]) |
| mkdir(path ptr[in, filename], mode flags[open_mode]) |
| rmdir(path ptr[in, filename]) |
| |
| fcntl$F_DUPFD(fd fd, cmd const[F_DUPFD], arg fd) fd |
| fcntl$F_DUPFD_CLOEXEC(fd fd, cmd const[F_DUPFD_CLOEXEC], arg fd) fd |
| fcntl$F_GETFD(fd fd, cmd const[F_GETFD]) |
| fcntl$F_GETFL(fd fd, cmd const[F_GETFL]) |
| fcntl$F_SETFD(fd fd, cmd const[F_SETFD], flags flags[fcntl_flags]) |
| fcntl$F_SETFL(fd fd, cmd const[F_SETFL], flags flags[fcntl_status]) |
| fcntl$F_SETLK(fd fd, cmd const[F_SETLK], lock ptr[in, flock]) |
| fcntl$F_SETLKW(fd fd, cmd const[F_SETLKW], lock ptr[in, flock]) |
| fcntl$F_GETLK(fd fd, cmd const[F_GETLK], lock ptr[in, flock]) |
| fcntl$F_GETOWN(fd fd, cmd const[F_GETOWN]) pid |
| fcntl$F_SETOWN(fd fd, cmd const[F_SETOWN], pid pid) |
| |
| mmap(addr vma, len len[addr], prot flags[mmap_prot], flags flags[mmap_flags], fd fd[opt], offset intptr) |
| munmap(addr vma, len len[addr]) |
| mprotect(addr vma, len len[addr], prot flags[mmap_prot]) |
| |
| # TODO: disabled because crashes kernel frequently. |
| # fork() |
| waitpid(pid pid, status ptr[out, int32], options flags[wait_options]) |
| nanosleep(req ptr[in, timespec], rem ptr[out, timespec, opt]) |
| |
| open_flags = O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, FASYNC, O_CLOEXEC, O_CREAT, O_DIRECTORY, O_EXCL, O_NOCTTY, O_NOFOLLOW, O_NONBLOCK, O_SYNC, O_TRUNC, __O_TMPFILE |
| open_mode = S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH |
| mmap_prot = PROT_EXEC, PROT_READ, PROT_WRITE, PROT_GROWSDOWN, PROT_GROWSUP |
| mmap_flags = MAP_SHARED, MAP_PRIVATE, MAP_32BIT, MAP_ANONYMOUS, MAP_DENYWRITE, MAP_EXECUTABLE, MAP_FILE, MAP_FIXED, MAP_GROWSDOWN, MAP_HUGETLB, MAP_LOCKED, MAP_NONBLOCK, MAP_NORESERVE, MAP_POPULATE, MAP_STACK |
| wait_options = WNOHANG, WUNTRACED |
| fcntl_flags = FD_CLOEXEC |
| fcntl_status = O_APPEND, FASYNC, O_NONBLOCK |
| flock_type = F_RDLCK, F_WRLCK, F_UNLCK |
| seek_whence = SEEK_SET, SEEK_CUR, SEEK_END |
| |
| timespec { |
| sec intptr |
| nsec intptr |
| } |
| |
| flock { |
| type flags[flock_type, int16] |
| whence flags[seek_whence, int16] |
| start intptr |
| len intptr |
| pid pid |
| } |
| |
| # TODO: |
| #define SYS_null 1 |
| #define SYS_block 2 |
| #define SYS_cache_invalidate 3 |
| #define SYS_reboot 4 |
| #define SYS_getpcoreid 7 |
| #define SYS_getvcoreid 8 |
| #define SYS_proc_create 10 |
| #define SYS_proc_run 11 |
| #define SYS_proc_destroy 12 |
| #define SYS_proc_yield 13 |
| #define SYS_change_vcore 14 |
| #define SYS_exec 16 |
| #define SYS_shared_page_alloc 22 |
| #define SYS_shared_page_free 23 |
| #define SYS_provision 24 |
| #define SYS_notify 25 |
| #define SYS_self_notify 26 |
| #define SYS_halt_core 27 |
| #define SYS_init_arsc 28 |
| #define SYS_change_to_m 29 |
| #define SYS_poke_ksched 30 |
| #define SYS_abort_sysc 31 |
| #define SYS_populate_va 32 |
| #define SYS_vmm_add_gpcs 34 |
| #define SYS_vc_entry 35 |
| #define SYS_pop_ctx 37 |
| #define SYS_vmm_poke_guest 38 |
| #define SYS_send_event 39 |
| #define SYS_vmm_ctl 40 |
| #define SYS_access 108 |
| #define SYS_umask 109 |
| #define SYS_wstat 121 |
| #define SYS_fwstat 122 |
| #define SYS_dup_fds_to 125 |
| #define SYS_tap_fds 126 |
| #define SYS_tcgetattr 141 |
| #define SYS_tcsetattr 142 |
| #define SYS_setuid 143 |
| #define SYS_setgid 144 |
| #define SYS_nbind 145 |
| #define SYS_nmount 146 |
| #define SYS_nunmount 147 |
| #define SYS_fd2path 149 |