diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-07-06 14:43:24 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-07-06 14:43:24 +0200 |
| commit | 04bd6c3d9e84645b320e888fa5c547e0b2b1be93 (patch) | |
| tree | b841cc3e24c7fbe98988948a7fdea53d2ca79a8f | |
| parent | 8c2335a205682fbbe311fb5ad4393419fd094a99 (diff) | |
pkg/instance: pass -os to execprog/fuzzer only for akaros
Only akaros needs OS, because the rest assume host OS.
But speciying OS for all OSes breaks patch testing on syzbot
because old execprog does not have os flag.
| -rw-r--r-- | pkg/instance/instance.go | 44 | ||||
| -rw-r--r-- | pkg/repro/repro.go | 13 | ||||
| -rw-r--r-- | syz-manager/manager.go | 8 | ||||
| -rw-r--r-- | tools/syz-crush/crush.go | 6 |
4 files changed, 50 insertions, 21 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 78859727b..ff3240f52 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -265,8 +265,9 @@ func (inst *inst) testInstance() error { if err != nil { return &TestError{Title: fmt.Sprintf("failed to copy test binary to VM: %v", err)} } - cmd := fmt.Sprintf("%v -test -executor=%v -name=test -os=%v -arch=%v -manager=%v -cover=0 -sandbox=%v", - fuzzerBin, executorBin, inst.cfg.TargetOS, inst.cfg.TargetArch, fwdAddr, inst.cfg.Sandbox) + + cmd := FuzzerCmd(fuzzerBin, executorBin, "test", inst.cfg.TargetOS, inst.cfg.TargetArch, fwdAddr, + inst.cfg.Sandbox, 0, 0, false, false, true) outc, errc, err := inst.vm.Run(5*time.Minute, nil, cmd) if err != nil { return fmt.Errorf("failed to run binary in VM: %v", err) @@ -322,10 +323,8 @@ func (inst *inst) testRepro() error { if !opts.Fault { opts.FaultCall = -1 } - cmdSyz := fmt.Sprintf("%v -executor=%v -os=%v -arch=%v -procs=%v -sandbox=%v"+ - " -fault_call=%v -fault_nth=%v -repeat=0 -cover=0 %v", - execprogBin, executorBin, cfg.TargetOS, cfg.TargetArch, cfg.Procs, opts.Sandbox, - opts.FaultCall, opts.FaultNth, vmProgFile) + cmdSyz := ExecprogCmd(execprogBin, executorBin, cfg.TargetOS, cfg.TargetArch, opts.Sandbox, + true, true, true, cfg.Procs, opts.FaultCall, opts.FaultNth, vmProgFile) if err := inst.testProgram(cmdSyz, 7*time.Minute); err != nil { return err } @@ -363,3 +362,36 @@ func (inst *inst) testProgram(command string, testTime time.Duration) error { } return &CrashError{Report: rep} } + +func FuzzerCmd(fuzzer, executor, name, OS, arch, fwdAddr, sandbox string, procs, verbosity int, + cover, debug, test bool) string { + osArg := "" + if OS == "akaros" { + // Only akaros needs OS, because the rest assume host OS. + // But speciying OS for all OSes breaks patch testing on syzbot + // because old execprog does not have os flag. + osArg = " -os=" + OS + } + return fmt.Sprintf("%v -executor=%v -name=%v -arch=%v%v -manager=%v -sandbox=%v"+ + " -procs=%v -v=%d -cover=%v -debug=%v -test=%v", + fuzzer, executor, name, arch, osArg, fwdAddr, sandbox, + procs, verbosity, cover, debug, test) +} + +func ExecprogCmd(execprog, executor, OS, arch, sandbox string, repeat, threaded, collide bool, + procs, faultCall, faultNth int, progFile string) string { + repeatCount := 1 + if repeat { + repeatCount = 0 + } + osArg := "" + if OS == "akaros" { + osArg = " -os=" + OS + } + return fmt.Sprintf("%v -executor=%v -arch=%v%v -sandbox=%v"+ + " -procs=%v -repeat=%v -threaded=%v -collide=%v -cover=0"+ + " -fault_call=%v -fault_nth=%v %v", + execprog, executor, arch, osArg, sandbox, + procs, repeatCount, threaded, collide, + faultCall, faultNth, progFile) +} diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go index 83eac9bde..4c3f8a93a 100644 --- a/pkg/repro/repro.go +++ b/pkg/repro/repro.go @@ -12,6 +12,7 @@ import ( "time" "github.com/google/syzkaller/pkg/csource" + instancePkg "github.com/google/syzkaller/pkg/instance" "github.com/google/syzkaller/pkg/log" "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/pkg/report" @@ -525,10 +526,6 @@ func (ctx *context) testProgs(entries []*prog.LogEntry, duration time.Duration, return false, fmt.Errorf("failed to copy to VM: %v", err) } - repeat := 1 - if opts.Repeat { - repeat = 0 - } if !opts.Fault { opts.FaultCall = -1 } @@ -543,10 +540,10 @@ func (ctx *context) testProgs(entries []*prog.LogEntry, duration time.Duration, } program += "]" } - command := fmt.Sprintf("%v -executor=%v -os=%v -arch=%v -cover=0 -procs=%v -repeat=%v"+ - " -sandbox %v -threaded=%v -collide=%v %v", - inst.execprogBin, inst.executorBin, ctx.cfg.TargetOS, ctx.cfg.TargetArch, opts.Procs, repeat, - opts.Sandbox, opts.Threaded, opts.Collide, vmProgFile) + + command := instancePkg.ExecprogCmd(inst.execprogBin, inst.executorBin, + ctx.cfg.TargetOS, ctx.cfg.TargetArch, opts.Sandbox, opts.Repeat, + opts.Threaded, opts.Collide, opts.Procs, -1, -1, vmProgFile) ctx.reproLog(2, "testing program (duration=%v, %+v): %s", duration, opts, program) return ctx.testImpl(inst.Instance, command, duration) } diff --git a/syz-manager/manager.go b/syz-manager/manager.go index 9a9fd4ffe..932513065 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -23,6 +23,7 @@ import ( "github.com/google/syzkaller/pkg/db" "github.com/google/syzkaller/pkg/gce" "github.com/google/syzkaller/pkg/hash" + "github.com/google/syzkaller/pkg/instance" "github.com/google/syzkaller/pkg/log" "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/pkg/report" @@ -577,10 +578,9 @@ func (mgr *Manager) runInstance(index int) (*Crash, error) { start := time.Now() atomic.AddUint32(&mgr.numFuzzing, 1) defer atomic.AddUint32(&mgr.numFuzzing, ^uint32(0)) - cmd := fmt.Sprintf("%v -executor=%v -name=vm-%v -os=%v -arch=%v -manager=%v -procs=%v"+ - " -cover=%v -sandbox=%v -debug=%v -v=%d", - fuzzerBin, executorBin, index, mgr.cfg.TargetOS, mgr.cfg.TargetArch, - fwdAddr, procs, mgr.cfg.Cover, mgr.cfg.Sandbox, *flagDebug, fuzzerV) + cmd := instance.FuzzerCmd(fuzzerBin, executorBin, fmt.Sprintf("vm-%v", index), + mgr.cfg.TargetOS, mgr.cfg.TargetArch, fwdAddr, mgr.cfg.Sandbox, procs, fuzzerV, + mgr.cfg.Cover, *flagDebug, false) outc, errc, err := inst.Run(time.Hour, mgr.vmStop, cmd) if err != nil { return nil, fmt.Errorf("failed to run fuzzer: %v", err) diff --git a/tools/syz-crush/crush.go b/tools/syz-crush/crush.go index bb07b72c3..ee020b74f 100644 --- a/tools/syz-crush/crush.go +++ b/tools/syz-crush/crush.go @@ -8,12 +8,12 @@ package main import ( "flag" - "fmt" "io/ioutil" "sync" "sync/atomic" "time" + "github.com/google/syzkaller/pkg/instance" "github.com/google/syzkaller/pkg/log" "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/pkg/report" @@ -98,8 +98,8 @@ func runInstance(cfg *mgrconfig.Config, reporter report.Reporter, vmPool *vm.Poo return } - cmd := fmt.Sprintf("%v -executor=%v -repeat=0 -procs=%v -sandbox=%v %v", - execprogBin, executorBin, cfg.Procs, cfg.Sandbox, logFile) + cmd := instance.ExecprogCmd(execprogBin, executorBin, cfg.TargetOS, cfg.TargetArch, cfg.Sandbox, + true, true, true, cfg.Procs, -1, -1, logFile) outc, errc, err := inst.Run(time.Hour, nil, cmd) if err != nil { log.Logf(0, "failed to run execprog: %v", err) |
