aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/instance
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-05-22 22:40:54 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-05-23 08:13:24 +0000
commit8f98448ed32de3ed37dd5bed05414b81e16e7437 (patch)
treeb2561a932b20a3414f134daad83a6ca373067eaf /pkg/instance
parent4c2072ee9db2f0fa4fab626800146043add2c3ed (diff)
pkg/instance: always use default exit conditions
We don't really need to overwrite it. For syz programs, don't ignore non-zero exit codes. This should enable syzkaller to find reproducers for "lost connection" bugs.
Diffstat (limited to 'pkg/instance')
-rw-r--r--pkg/instance/execprog.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/pkg/instance/execprog.go b/pkg/instance/execprog.go
index acade5e8e..4cc8dd1f5 100644
--- a/pkg/instance/execprog.go
+++ b/pkg/instance/execprog.go
@@ -20,7 +20,6 @@ import (
type ExecutorLogger func(int, string, ...interface{})
type OptionalConfig struct {
- ExitCondition vm.ExitCondition
Logf ExecutorLogger
OldFlagsCompatMode bool
BeforeContextLen int
@@ -41,6 +40,13 @@ type RunResult struct {
Report *report.Report
}
+const (
+ // It's reasonable to expect that tools/syz-execprog should not normally
+ // return a non-zero exit code.
+ syzExitConditions = vm.ExitTimeout | vm.ExitNormal
+ binExitConditions = vm.ExitTimeout | vm.ExitNormal | vm.ExitError
+)
+
func SetupExecProg(vmInst *vm.Instance, mgrCfg *mgrconfig.Config, reporter *report.Reporter,
opt *OptionalConfig) (*ExecProgInstance, error) {
execprogBin, err := vmInst.Copy(mgrCfg.ExecprogBin)
@@ -74,9 +80,6 @@ func SetupExecProg(vmInst *vm.Instance, mgrCfg *mgrconfig.Config, reporter *repo
if ret.Logf == nil {
ret.Logf = func(int, string, ...interface{}) {}
}
- if ret.ExitCondition == 0 {
- ret.ExitCondition = vm.ExitTimeout | vm.ExitNormal | vm.ExitError
- }
return ret, nil
}
@@ -94,7 +97,8 @@ func CreateExecProgInstance(vmPool *vm.Pool, vmIndex int, mgrCfg *mgrconfig.Conf
return ret, nil
}
-func (inst *ExecProgInstance) runCommand(command string, duration time.Duration) (*RunResult, error) {
+func (inst *ExecProgInstance) runCommand(command string, duration time.Duration,
+ exitCondition vm.ExitCondition) (*RunResult, error) {
var prefixOutput []byte
if inst.StraceBin != "" {
filterCalls := ""
@@ -108,7 +112,7 @@ func (inst *ExecProgInstance) runCommand(command string, duration time.Duration)
command = inst.StraceBin + filterCalls + ` -s 100 -x -f ` + command
prefixOutput = []byte(fmt.Sprintf("%s\n\n<...>\n", command))
}
- opts := []any{inst.ExitCondition}
+ opts := []any{exitCondition}
if inst.BeforeContextLen != 0 {
opts = append(opts, vm.OutputSize(inst.BeforeContextLen))
}
@@ -133,7 +137,7 @@ func (inst *ExecProgInstance) runBinary(bin string, duration time.Duration) (*Ru
if err != nil {
return nil, &TestError{Title: fmt.Sprintf("failed to copy binary to VM: %v", err)}
}
- return inst.runCommand(bin, duration)
+ return inst.runCommand(bin, duration, binExitConditions)
}
func (inst *ExecProgInstance) RunCProg(p *prog.Prog, duration time.Duration,
@@ -170,7 +174,7 @@ func (inst *ExecProgInstance) RunSyzProgFile(progFile string, duration time.Dura
command := ExecprogCmd(inst.execprogBin, inst.executorBin, target.OS, target.Arch, opts.Sandbox,
opts.SandboxArg, opts.Repeat, opts.Threaded, opts.Collide, opts.Procs, faultCall, opts.FaultNth,
!inst.OldFlagsCompatMode, inst.mgrCfg.Timeouts.Slowdown, vmProgFile)
- return inst.runCommand(command, duration)
+ return inst.runCommand(command, duration, syzExitConditions)
}
func (inst *ExecProgInstance) RunSyzProg(syzProg []byte, duration time.Duration,