aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-04-06 11:32:21 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-04-06 17:14:35 +0200
commit4a7cb474c2f19630d8b1c2609f69ea25f249d535 (patch)
tree688e6ea3f8928ce50629506ddcd69cc4303c7de5
parent86b4b7f81837a5f26db1e1e2cbbefc7c3885fb08 (diff)
pkg/instance: explicitly specify optional fuzzer arguments
Otherwise we get problems while testing patches for older syzkaller versions, which didn't support optional arguments. Adjust tests so that problems with how OldFuzzerCmd handles such arguments could be seen.
-rw-r--r--pkg/instance/instance.go29
-rw-r--r--pkg/instance/instance_test.go2
-rw-r--r--syz-manager/manager.go6
-rw-r--r--tools/syz-runtest/runtest.go4
4 files changed, 25 insertions, 16 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go
index c225f9696..e670a2c64 100644
--- a/pkg/instance/instance.go
+++ b/pkg/instance/instance.go
@@ -437,6 +437,11 @@ func (inst *inst) testProgram(command string, testTime time.Duration) error {
return &CrashError{Report: rep}
}
+type OptionalFuzzerArgs struct {
+ Slowdown int
+ RawCover bool
+}
+
type FuzzerCmdArgs struct {
Fuzzer string
Executor string
@@ -451,8 +456,7 @@ type FuzzerCmdArgs struct {
Debug bool
Test bool
Runtest bool
- Slowdown int
- RawCover bool
+ Optional *OptionalFuzzerArgs
}
func FuzzerCmd(args *FuzzerCmdArgs) string {
@@ -471,16 +475,13 @@ func FuzzerCmd(args *FuzzerCmdArgs) string {
if args.Verbosity != 0 {
verbosityArg = fmt.Sprintf(" -vv=%v", args.Verbosity)
}
- flags := []tool.Flag{}
- if args.Slowdown > 0 {
- flags = append(flags, tool.Flag{Name: "slowdown", Value: fmt.Sprint(args.Slowdown)})
- }
- if args.RawCover {
- flags = append(flags, tool.Flag{Name: "raw_cover", Value: "true"})
- }
optionalArg := ""
- if len(flags) > 0 {
- optionalArg += " " + tool.OptionalFlags(flags)
+ if args.Optional != nil {
+ flags := []tool.Flag{
+ {Name: "slowdown", Value: fmt.Sprint(args.Optional.Slowdown)},
+ {Name: "raw_cover", Value: fmt.Sprint(args.Optional.RawCover)},
+ }
+ optionalArg = " " + tool.OptionalFlags(flags)
}
return fmt.Sprintf("%v -executor=%v -name=%v -arch=%v%v -manager=%v -sandbox=%v"+
" -procs=%v -cover=%v -debug=%v -test=%v%v%v%v",
@@ -490,10 +491,14 @@ func FuzzerCmd(args *FuzzerCmdArgs) string {
func OldFuzzerCmd(fuzzer, executor, name, OS, arch, fwdAddr, sandbox string, procs int,
cover, test, optionalFlags bool, slowdown int) string {
+ var optional *OptionalFuzzerArgs
+ if optionalFlags {
+ optional = &OptionalFuzzerArgs{Slowdown: slowdown}
+ }
return FuzzerCmd(&FuzzerCmdArgs{Fuzzer: fuzzer, Executor: executor, Name: name,
OS: OS, Arch: arch, FwdAddr: fwdAddr, Sandbox: sandbox, Procs: procs,
Verbosity: 0, Cover: cover, Debug: false, Test: test, Runtest: false,
- Slowdown: slowdown})
+ Optional: optional})
}
func ExecprogCmd(execprog, executor, OS, arch, sandbox string, repeat, threaded, collide bool,
diff --git a/pkg/instance/instance_test.go b/pkg/instance/instance_test.go
index 92903512c..2f5c08625 100644
--- a/pkg/instance/instance_test.go
+++ b/pkg/instance/instance_test.go
@@ -33,7 +33,7 @@ func TestFuzzerCmd(t *testing.T) {
flagDebug := flags.Bool("debug", false, "debug output from executor")
flagV := flags.Int("v", 0, "verbosity")
cmdLine := OldFuzzerCmd(os.Args[0], "/myexecutor", "myname", targets.Linux, targets.I386, "localhost:1234",
- "namespace", 3, true, true, false, 0)
+ "namespace", 3, true, true, false, 5)
args := strings.Split(cmdLine, " ")[1:]
if err := flags.Parse(args); err != nil {
t.Fatal(err)
diff --git a/syz-manager/manager.go b/syz-manager/manager.go
index 9d5662188..09762dd64 100644
--- a/syz-manager/manager.go
+++ b/syz-manager/manager.go
@@ -694,8 +694,10 @@ func (mgr *Manager) runInstanceInner(index int, instanceName string) (*report.Re
Debug: *flagDebug,
Test: false,
Runtest: false,
- Slowdown: mgr.cfg.Timeouts.Slowdown,
- RawCover: mgr.cfg.RawCover,
+ Optional: &instance.OptionalFuzzerArgs{
+ Slowdown: mgr.cfg.Timeouts.Slowdown,
+ RawCover: mgr.cfg.RawCover,
+ },
}
cmd := instance.FuzzerCmd(args)
outc, errc, err := inst.Run(mgr.cfg.Timeouts.VMRunningTime, mgr.vmStop, cmd)
diff --git a/tools/syz-runtest/runtest.go b/tools/syz-runtest/runtest.go
index 2f32ca285..621c3e958 100644
--- a/tools/syz-runtest/runtest.go
+++ b/tools/syz-runtest/runtest.go
@@ -187,7 +187,9 @@ func (mgr *Manager) boot(name string, index int) (*report.Report, error) {
Debug: mgr.debug,
Test: false,
Runtest: true,
- Slowdown: mgr.cfg.Timeouts.Slowdown,
+ Optional: &instance.OptionalFuzzerArgs{
+ Slowdown: mgr.cfg.Timeouts.Slowdown,
+ },
}
cmd := instance.FuzzerCmd(args)
outc, errc, err := inst.Run(time.Hour, mgr.vmStop, cmd)