aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ipc/ipcconfig
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-03 18:12:24 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-08-03 18:12:24 +0200
commit6bfd4f09db1079ee95e0ee10f770e34499e9eeee (patch)
treedcad32286f42c6cb8533ec4b7f5ddfab4ba3c8b0 /pkg/ipc/ipcconfig
parent5ff1f9faece0ff7318d05c21a3efd0b44a009ac8 (diff)
pkg/ipc: move flags into subpackage
Move all ipc flags into pkg/ipc/ipcconfig package so that importing pkg/ipc does pull in the flags.
Diffstat (limited to 'pkg/ipc/ipcconfig')
-rw-r--r--pkg/ipc/ipcconfig/ipcconfig.go71
1 files changed, 71 insertions, 0 deletions
diff --git a/pkg/ipc/ipcconfig/ipcconfig.go b/pkg/ipc/ipcconfig/ipcconfig.go
new file mode 100644
index 000000000..6f13ad137
--- /dev/null
+++ b/pkg/ipc/ipcconfig/ipcconfig.go
@@ -0,0 +1,71 @@
+// Copyright 2018 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.
+
+package ipcconfig
+
+import (
+ "flag"
+ "fmt"
+
+ "github.com/google/syzkaller/pkg/ipc"
+ "github.com/google/syzkaller/prog"
+ "github.com/google/syzkaller/sys/targets"
+)
+
+var (
+ flagExecutor = flag.String("executor", "./syz-executor", "path to executor binary")
+ flagThreaded = flag.Bool("threaded", true, "use threaded mode in executor")
+ flagCollide = flag.Bool("collide", true, "collide syscalls to provoke data races")
+ flagSignal = flag.Bool("cover", false, "collect feedback signals (coverage)")
+ flagSandbox = flag.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace)")
+ flagDebug = flag.Bool("debug", false, "debug output from executor")
+ flagTimeout = flag.Duration("timeout", 0, "execution timeout")
+ flagAbortSignal = flag.Int("abort_signal", 0, "initial signal to send to executor"+
+ " in error conditions; upgrades to SIGKILL if executor does not exit")
+ flagBufferSize = flag.Uint64("buffer_size", 0, "internal buffer size (in bytes) for executor output")
+)
+
+func Default(target *prog.Target) (*ipc.Config, *ipc.ExecOpts, error) {
+ c := &ipc.Config{
+ Executor: *flagExecutor,
+ Timeout: *flagTimeout,
+ AbortSignal: *flagAbortSignal,
+ BufferSize: *flagBufferSize,
+ RateLimit: target.OS == "akaros",
+ }
+ if *flagSignal {
+ c.Flags |= ipc.FlagSignal
+ }
+ if *flagDebug {
+ c.Flags |= ipc.FlagDebug
+ }
+ switch *flagSandbox {
+ case "none":
+ case "setuid":
+ c.Flags |= ipc.FlagSandboxSetuid
+ case "namespace":
+ c.Flags |= ipc.FlagSandboxNamespace
+ default:
+ return nil, nil, fmt.Errorf("flag sandbox must contain one of none/setuid/namespace")
+ }
+
+ sysTarget := targets.Get(target.OS, target.Arch)
+ if sysTarget.ExecutorUsesShmem {
+ c.Flags |= ipc.FlagUseShmem
+ }
+ if sysTarget.ExecutorUsesForkServer {
+ c.Flags |= ipc.FlagUseForkServer
+ }
+
+ opts := &ipc.ExecOpts{
+ Flags: ipc.FlagDedupCover,
+ }
+ if *flagThreaded {
+ opts.Flags |= ipc.FlagThreaded
+ }
+ if *flagCollide {
+ opts.Flags |= ipc.FlagCollide
+ }
+
+ return c, opts, nil
+}