Skip to content
Permalink
Browse files

sys/netbsd: Adding more syscalls

* sys/netbsd: Adding more syscalls

* Added lwp create structures

* Added a few lwp flags

* completed _lwp* syscalls

* add clone syscall

* fix errors, recheck arguments
  • Loading branch information...
R3x authored and dvyukov committed Jul 1, 2019
1 parent 699d644 commit 907bf74686129436f81aa40336ee89f7cc01b0b4
@@ -125,7 +125,7 @@

#if GOARCH_amd64
#define GOARCH "amd64"
#define SYZ_REVISION "96be9781647711050e565dac893dacbf183be15d"
#define SYZ_REVISION "71ea2d6047354a28057976d7ea40a5f24673a27c"
#define SYZ_EXECUTOR_USES_FORK_SERVER 1
#define SYZ_EXECUTOR_USES_SHMEM 1
#define SYZ_PAGE_SIZE 4096

#if GOARCH_amd64
const call_t syscalls[] = {
{"__clone", 287},
{"_lwp_continue", 314},
{"_lwp_create", 309},
{"_lwp_ctl", 325},
{"_lwp_detach", 319},
{"_lwp_exit", 310},
{"_lwp_getname", 324},
{"_lwp_getprivate", 316},
{"_lwp_kill", 318},
{"_lwp_self", 311},
{"_lwp_setname", 323},
{"_lwp_setprivate", 317},
{"_lwp_suspend", 313},
{"_lwp_unpark", 321},
{"_lwp_unpark_all", 322},
{"_lwp_wait", 312},
{"_lwp_wakeup", 315},
{"accept", 30},
{"accept$inet", 30},
{"accept$inet6", 30},
{"clock_nanosleep", 477},
{"clock_settime", 428},
{"close", 6},
{"compat_50__lwp_park", 320},
{"connect", 98},
{"connect$inet", 98},
{"connect$inet6", 98},
{"pipe", 42},
{"pipe2", 453},
{"poll", 209},
{"pread", 173},
{"preadv", 289},
{"ptrace", 26},
{"pwrite", 174},
{"pwritev", 290},
{"read", 3},
{"readlink", 58},
@@ -20,9 +20,11 @@ openat(fd fd_dir[opt], file ptr[in, filename], flags flags[open_flags], mode fla
close(fd fd)
read(fd fd, buf buffer[out], count len[buf])
readv(fd fd, vec ptr[in, array[iovec_out]], vlen len[vec])
pread(fd fd, buf buffer[in], nbyte len[buf], off fileoff)
preadv(fd fd, vec ptr[in, array[iovec_out]], vlen len[vec], off fileoff)
write(fd fd, buf buffer[in], count len[buf])
writev(fd fd, vec ptr[in, array[iovec_in]], vlen len[vec])
pwrite(fd fd, buf buffer[in], nbyte len[buf], off fileoff)
pwritev(fd fd, vec ptr[in, array[iovec_in]], vlen len[vec], off fileoff)
lseek(fd fd, offset fileoff, whence flags[seek_whence])
dup(oldfd fd) fd
@@ -31,7 +31,9 @@ SYS_lseek = 199
SYS_open = 5
SYS_openat = 468
SYS_pipe2 = 453
SYS_pread = 173
SYS_preadv = 289
SYS_pwrite = 174
SYS_pwritev = 290
SYS_read = 3
SYS_readv = 120

Large diffs are not rendered by default.

@@ -0,0 +1,61 @@
# Copyright 2019 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/types.h>
include <sys/lwp.h>
include <sys/lwpctl.h>
include <sys/ucontext.h>
include <sys/signal.h>

resource lwpid[int32]: 0, 0xffffffffffffffff

_lwp_create(uc ptr[in, ucontext_t], flags flags[lwp_flags], new_lwp ptr[out, lwpid])
_lwp_exit()
_lwp_self() lwpid
_lwp_wait(wait_for lwpid, departed ptr[in, lwpid])
_lwp_suspend(target lwpid)
_lwp_continue(target lwpid)
_lwp_wakeup(target lwpid)
_lwp_getprivate()
_lwp_setprivate(data ptr[in, intptr])
_lwp_kill(target lwpid, sig int32)
_lwp_detach(target lwpid)
compat_50__lwp_park(ts ptr[in, timespec], unpark lwpid, hint ptr[in, intptr, opt], unparkhint ptr[in, intptr, opt])
_lwp_unpark(target lwpid, hint ptr[in, intptr, opt])
_lwp_unpark_all(targets ptr[in, array[lwpid]], ntargets len[targets], hint ptr[in, intptr, opt])
_lwp_setname(target lwpid, name ptr[in, string])
_lwp_getname(target lwpid, name ptr[out, string], size bytesize[name])
_lwp_ctl(features int32, address ptr[in, ptr[in, lwpctl]])

ucontext_t {
uc_flags flags[ucontext_flags, int32]
uc_link ptr[in, ucontext_t, opt]
uc_sigmask sigset_t
uc_stack stack_t
uc_mcontext mcontext_t
}

stack_t {
ss_sp int64
ss_size int64
ss_flags flags[stack_flags, int32]
}

mcontext_t {
__gregs int64
_mc_tlsbase int64
__fpregs string
}

sigset_t {
__bits array[int32, 4]
}

lwpctl {
lc_curcpu int32
lc_pctr int32
}

lwp_flags = LWP_DETACHED, LWP_SUSPENDED
ucontext_flags = _UC_SIGMASK, _UC_STACK, _UC_CPU, _UC_FPU, _UC_MD
stack_flags = SS_DISABLE, SS_ONSTACK
@@ -0,0 +1,27 @@
# AUTOGENERATED FILE
LWP_DETACHED = 64
LWP_SUSPENDED = 128
SS_DISABLE = 4
SS_ONSTACK = 1
SYS__lwp_continue = 314
SYS__lwp_create = 309
SYS__lwp_ctl = 325
SYS__lwp_detach = 319
SYS__lwp_exit = 310
SYS__lwp_getname = 324
SYS__lwp_getprivate = 316
SYS__lwp_kill = 318
SYS__lwp_self = 311
SYS__lwp_setname = 323
SYS__lwp_setprivate = 317
SYS__lwp_suspend = 313
SYS__lwp_unpark = 321
SYS__lwp_unpark_all = 322
SYS__lwp_wait = 312
SYS__lwp_wakeup = 315
SYS_compat_50__lwp_park = 320
_UC_CPU = 4
_UC_FPU = 8
_UC_MD = 1074724896
_UC_SIGMASK = 1
_UC_STACK = 2
@@ -16,6 +16,7 @@ include <time.h>
include <signal.h>
include <sys/wait.h>
include <sys/ptrace.h>
include <sys/sched.h>

syz_execute_func(text ptr[in, text[target]])

@@ -111,6 +112,7 @@ wait4(pid pid, status ptr[out, int32, opt], options flags[wait_options], ru ptr[

exit(code intptr)
ptrace(request intptr, pid pid, addr ptr[out, intptr], data intptr)
__clone(flags flags[clone_flags], sp buffer[in]) pid

pollfd {
fd fd
@@ -208,3 +210,4 @@ fcntl_lock = F_SETLK, F_SETLKW, F_GETLK
fcntl_flags = FD_CLOEXEC
fcntl_status = O_APPEND, O_ASYNC, O_NONBLOCK, O_DSYNC, O_RSYNC, O_ALT_IO, O_DIRECT, O_NOSIGPIPE
flock_type = F_RDLCK, F_WRLCK, F_UNLCK
clone_flags = CLONE_CSIGNAL, CLONE_VM, CLONE_FS, CLONE_FILES, CLONE_SIGHAND, CLONE_PID, CLONE_PTRACE, CLONE_VFORK
@@ -9,6 +9,14 @@ CLOCK_PROF = 2
CLOCK_REALTIME = 0
CLOCK_THREAD_CPUTIME_ID = 536870912
CLOCK_VIRTUAL = 1
CLONE_CSIGNAL = 255
CLONE_FILES = 1024
CLONE_FS = 512
CLONE_PID = 4096
CLONE_PTRACE = 8192
CLONE_SIGHAND = 2048
CLONE_VFORK = 16384
CLONE_VM = 256
FD_CLOEXEC = 1
F_DUPFD = 0
F_DUPFD_CLOEXEC = 12
@@ -63,6 +71,7 @@ RLIMIT_RSS = 5
RLIMIT_STACK = 3
RUSAGE_CHILDREN = 18446744073709551615
RUSAGE_SELF = 0
SYS___clone = 287
SYS_chdir = 12
SYS_chmod = 15
SYS_chown = 16

0 comments on commit 907bf74

Please sign in to comment.
You can’t perform that action at this time.