aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaura Peskin <pesk@google.com>2024-09-16 17:03:51 -0700
committerAleksandr Nogikh <nogikh@google.com>2024-09-24 14:52:23 +0000
commit349a68c4b056a06438a1e75e9b8a3a583b06d511 (patch)
tree7a095d526b059ff69ccadee7d20a89e1c4110c67
parent5643e0e933eb9fd69bb78740a8f3967b4d37bc0e (diff)
tools/syz-execprog: pass the VM type to execprog
This makes it possible to skip certain machine checks depending on the VM type, as syz-manager already does.
-rw-r--r--pkg/instance/execprog.go2
-rw-r--r--pkg/instance/instance.go6
-rw-r--r--pkg/instance/instance_test.go6
-rw-r--r--tools/syz-execprog/execprog.go2
4 files changed, 11 insertions, 5 deletions
diff --git a/pkg/instance/execprog.go b/pkg/instance/execprog.go
index 4ab5c09a7..401da784e 100644
--- a/pkg/instance/execprog.go
+++ b/pkg/instance/execprog.go
@@ -177,7 +177,7 @@ func (inst *ExecProgInstance) RunSyzProgFile(progFile string, duration time.Dura
if opts.Fault {
faultCall = opts.FaultCall
}
- command := ExecprogCmd(inst.execprogBin, inst.executorBin, target.OS, target.Arch, opts.Sandbox,
+ command := ExecprogCmd(inst.execprogBin, inst.executorBin, target.OS, target.Arch, inst.mgrCfg.Type, 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, exitCondition)
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go
index 4c877a229..ef8860330 100644
--- a/pkg/instance/instance.go
+++ b/pkg/instance/instance.go
@@ -442,8 +442,9 @@ func (inst *inst) csourceOptions() (csource.Options, error) {
return opts, nil
}
-func ExecprogCmd(execprog, executor, OS, arch, sandbox string, sandboxArg int, repeat, threaded, collide bool,
- procs, faultCall, faultNth int, optionalFlags bool, slowdown int, progFile string) string {
+func ExecprogCmd(execprog, executor, OS, arch, vmType, sandbox string, sandboxArg int, repeat,
+ threaded, collide bool, procs, faultCall, faultNth int, optionalFlags bool, slowdown int,
+ progFile string) string {
repeatCount := 1
if repeat {
repeatCount = 0
@@ -463,6 +464,7 @@ func ExecprogCmd(execprog, executor, OS, arch, sandbox string, sandboxArg int, r
optionalArg += " " + tool.OptionalFlags([]tool.Flag{
{Name: "slowdown", Value: fmt.Sprint(slowdown)},
{Name: "sandboxArg", Value: fmt.Sprint(sandboxArg)},
+ {Name: "type", Value: fmt.Sprint(vmType)},
})
}
diff --git a/pkg/instance/instance_test.go b/pkg/instance/instance_test.go
index 283921224..40328fb15 100644
--- a/pkg/instance/instance_test.go
+++ b/pkg/instance/instance_test.go
@@ -16,7 +16,9 @@ import (
func TestExecprogCmd(t *testing.T) {
// IMPORTANT: if this test fails, do not fix it by changing flags here!
- // See comment in TestFuzzerCmd.
+ // This test checks that an old version of syz-execprog can parse flags generated by the
+ // current ExecprogCmd.
+ // If you need to make changes to syz-execprog's flags, consider using `OptionalFlags`.
flags := flag.NewFlagSet("", flag.ContinueOnError)
flagOS := flags.String("os", runtime.GOOS, "target os")
flagArch := flags.String("arch", "", "target arch")
@@ -33,7 +35,7 @@ func TestExecprogCmd(t *testing.T) {
flagSignal := flags.Bool("cover", false, "collect feedback signals (coverage)")
flagSandbox := flags.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace/android)")
flagSlowdown := flags.Int("slowdown", 1, "")
- cmdLine := ExecprogCmd(os.Args[0], "/myexecutor", targets.FreeBSD, targets.I386,
+ cmdLine := ExecprogCmd(os.Args[0], "/myexecutor", targets.FreeBSD, targets.I386, "vmtype",
"namespace", 3, true, false, true, 7, 2, 3, true, 10, "myprog")
args := strings.Split(cmdLine, " ")[1:]
if err := tool.ParseFlags(flags, args); err != nil {
diff --git a/tools/syz-execprog/execprog.go b/tools/syz-execprog/execprog.go
index 550b3c114..d108f87fa 100644
--- a/tools/syz-execprog/execprog.go
+++ b/tools/syz-execprog/execprog.go
@@ -37,6 +37,7 @@ import (
var (
flagOS = flag.String("os", runtime.GOOS, "target os")
flagArch = flag.String("arch", runtime.GOARCH, "target arch")
+ flagType = flag.String("type", "", "target VM type")
flagCoverFile = flag.String("coverfile", "", "write coverage to the file")
flagRepeat = flag.Int("repeat", 1, "repeat execution that many times (0 for infinite loop)")
flagProcs = flag.Int("procs", 2*runtime.NumCPU(), "number of parallel processes to execute programs")
@@ -163,6 +164,7 @@ func main() {
Config: rpcserver.Config{
Config: vminfo.Config{
Target: target,
+ VMType: *flagType,
Features: features,
Syscalls: requestedSyscalls,
Debug: *flagDebug,