Skip to content

Commit 9a9b616

Browse files
committed
all: configure proc restart freq in syz-execprog
If we use a non-default restart frequence during fuzzing, we should keep doing so during bug reproduction.
1 parent f270543 commit 9a9b616

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

pkg/csource/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ type Options struct {
2626
Slowdown int `json:"slowdown"`
2727
Sandbox string `json:"sandbox"`
2828
SandboxArg int `json:"sandbox_arg"`
29+
// ProcRestartFreq is how often syz-executor should restart its procs.
30+
// ProcRestartFreq=0 corresponds to its default value.
31+
ProcRestartFreq int `json:"proc_restart_freq"`
2932

3033
Leak bool `json:"leak,omitempty"` // do leak checking
3134

pkg/csource/options_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ func enumerateField(OS string, opt Options, field int) []Options {
267267
fld.SetInt(val)
268268
opts = append(opts, opt)
269269
}
270+
} else if fldName == "ProcRestartFreq" {
271+
for _, val := range []int64{0, 100} {
272+
fld.SetInt(val)
273+
opts = append(opts, opt)
274+
}
270275
} else if fldName == "LegacyOptions" {
271276
opts = append(opts, opt)
272277
} else if fld.Kind() == reflect.Bool {

pkg/instance/instance.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ func ExecprogCmd(execprog, executor, OS, arch, vmType string, opts csource.Optio
485485
{Name: "slowdown", Value: fmt.Sprint(slowdown)},
486486
{Name: "sandboxArg", Value: fmt.Sprint(opts.SandboxArg)},
487487
{Name: "type", Value: fmt.Sprint(vmType)},
488+
{Name: "restart_freq", Value: fmt.Sprint(opts.ProcRestartFreq)},
488489
})
489490
}
490491
return fmt.Sprintf("%v -executor=%v -arch=%v%v -sandbox=%v"+

pkg/repro/repro.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,13 @@ var progSimplifies = []Simplify{
874874
opts.Procs = 1
875875
return true
876876
},
877+
func(opts *csource.Options) bool {
878+
if opts.ProcRestartFreq == 0 {
879+
return false
880+
}
881+
opts.ProcRestartFreq = 0
882+
return true
883+
},
877884
func(opts *csource.Options) bool {
878885
if opts.Procs == 1 {
879886
return false

tools/syz-execprog/execprog.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,26 @@ import (
3535
)
3636

3737
var (
38-
flagOS = flag.String("os", runtime.GOOS, "target os")
39-
flagArch = flag.String("arch", runtime.GOARCH, "target arch")
40-
flagType = flag.String("type", "", "target VM type")
41-
flagCoverFile = flag.String("coverfile", "", "write coverage to the file")
42-
flagRepeat = flag.Int("repeat", 1, "repeat execution that many times (0 for infinite loop)")
43-
flagProcs = flag.Int("procs", 2*runtime.NumCPU(), "number of parallel processes to execute programs")
44-
flagOutput = flag.Bool("output", false, "write programs and results to stdout")
45-
flagHints = flag.Bool("hints", false, "do a hints-generation run")
46-
flagEnable = flag.String("enable", "none", "enable only listed additional features")
47-
flagDisable = flag.String("disable", "none", "enable all additional features except listed")
48-
flagExecutor = flag.String("executor", "./syz-executor", "path to executor binary")
49-
flagThreaded = flag.Bool("threaded", true, "use threaded mode in executor")
50-
flagSignal = flag.Bool("cover", false, "collect feedback signals (coverage)")
51-
flagSandbox = flag.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace/android)")
52-
flagSandboxArg = flag.Int("sandbox_arg", 0, "argument for sandbox runner to adjust it via config")
53-
flagDebug = flag.Bool("debug", false, "debug output from executor")
54-
flagSlowdown = flag.Int("slowdown", 1, "execution slowdown caused by emulation/instrumentation")
55-
flagUnsafe = flag.Bool("unsafe", false, "use unsafe program deserialization mode")
56-
flagGlob = flag.String("glob", "", "run glob expansion request")
38+
flagOS = flag.String("os", runtime.GOOS, "target os")
39+
flagArch = flag.String("arch", runtime.GOARCH, "target arch")
40+
flagType = flag.String("type", "", "target VM type")
41+
flagCoverFile = flag.String("coverfile", "", "write coverage to the file")
42+
flagRepeat = flag.Int("repeat", 1, "repeat execution that many times (0 for infinite loop)")
43+
flagProcs = flag.Int("procs", 2*runtime.NumCPU(), "number of parallel processes to execute programs")
44+
flagOutput = flag.Bool("output", false, "write programs and results to stdout")
45+
flagHints = flag.Bool("hints", false, "do a hints-generation run")
46+
flagEnable = flag.String("enable", "none", "enable only listed additional features")
47+
flagDisable = flag.String("disable", "none", "enable all additional features except listed")
48+
flagExecutor = flag.String("executor", "./syz-executor", "path to executor binary")
49+
flagThreaded = flag.Bool("threaded", true, "use threaded mode in executor")
50+
flagSignal = flag.Bool("cover", false, "collect feedback signals (coverage)")
51+
flagSandbox = flag.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace/android)")
52+
flagSandboxArg = flag.Int("sandbox_arg", 0, "argument for sandbox runner to adjust it via config")
53+
flagDebug = flag.Bool("debug", false, "debug output from executor")
54+
flagSlowdown = flag.Int("slowdown", 1, "execution slowdown caused by emulation/instrumentation")
55+
flagUnsafe = flag.Bool("unsafe", false, "use unsafe program deserialization mode")
56+
flagGlob = flag.String("glob", "", "run glob expansion request")
57+
flagRestartFreq = flag.Int("restart_freq", 0, "restart procs every X executions")
5758

5859
// The in the stress mode resembles simple unguided fuzzer.
5960
// This mode can be used as an intermediate step when porting syzkaller to a new OS,
@@ -175,8 +176,9 @@ func main() {
175176
Sandbox: sandbox,
176177
SandboxArg: int64(*flagSandboxArg),
177178
},
178-
Procs: *flagProcs,
179-
Slowdown: *flagSlowdown,
179+
Procs: *flagProcs,
180+
Slowdown: *flagSlowdown,
181+
ProcRestartFreq: *flagRestartFreq,
180182
},
181183
Executor: *flagExecutor,
182184
HandleInterrupts: true,

0 commit comments

Comments
 (0)