aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-11-14 16:59:09 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-11-16 09:58:54 +0100
commitb5c36524a29838b0ec9345fc1a07daeebf50c833 (patch)
treeb25f237098577e50e3c1387454da625b50280478 /pkg
parentcdac920beb540736200639a6254e6dc01422e705 (diff)
sys/targets: add HostFuzzer flag
Move HostFuzzer from vm/qemu. It's needed in a number of other packages and strictly saying is not specific to qemu (it just happened that both fuchsia and akaros only support qemu).
Diffstat (limited to 'pkg')
-rw-r--r--pkg/host/host.go12
-rw-r--r--pkg/instance/instance.go9
-rw-r--r--pkg/ipc/ipc.go6
3 files changed, 12 insertions, 15 deletions
diff --git a/pkg/host/host.go b/pkg/host/host.go
index f18233085..216b9158d 100644
--- a/pkg/host/host.go
+++ b/pkg/host/host.go
@@ -10,6 +10,7 @@ import (
"github.com/google/syzkaller/pkg/log"
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/prog"
+ "github.com/google/syzkaller/sys/targets"
)
// DetectSupportedSyscalls returns list on supported and unsupported syscalls on the host.
@@ -19,9 +20,8 @@ func DetectSupportedSyscalls(target *prog.Target, sandbox string) (
log.Logf(1, "detecting supported syscalls")
supported := make(map[*prog.Syscall]bool)
unsupported := make(map[*prog.Syscall]string)
- // Akaros does not have own host and parasitizes on some other OS.
- switch target.OS {
- case "akaros", "fuchsia", "test":
+ // These do not have own host and parasitize on some other OS.
+ if targets.Get(target.OS, target.Arch).HostFuzzer {
for _, c := range target.Syscalls {
supported[c] = true
}
@@ -111,8 +111,7 @@ func Check(target *prog.Target) (*Features, error) {
FeatureKCSAN: {Name: "concurrency sanitizer", Reason: unsupported},
FeatureDevlinkPCI: {Name: "devlink PCI setup", Reason: unsupported},
}
- switch target.OS {
- case "akaros", "fuchsia", "test":
+ if targets.Get(target.OS, target.Arch).HostFuzzer {
return res, nil
}
for n, check := range checkFeature {
@@ -132,8 +131,7 @@ func Check(target *prog.Target) (*Features, error) {
// Setup enables and does any one-time setup for the requested features on the host.
// Note: this can be called multiple times and must be idempotent.
func Setup(target *prog.Target, features *Features, featureFlags csource.Features, executor string) error {
- switch target.OS {
- case "akaros", "fuchsia":
+ if targets.Get(target.OS, target.Arch).HostFuzzer {
return nil
}
args := []string{"setup"}
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go
index ccb5265d1..775366667 100644
--- a/pkg/instance/instance.go
+++ b/pkg/instance/instance.go
@@ -24,6 +24,7 @@ import (
"github.com/google/syzkaller/pkg/report"
"github.com/google/syzkaller/pkg/vcs"
"github.com/google/syzkaller/prog"
+ "github.com/google/syzkaller/sys/targets"
"github.com/google/syzkaller/vm"
)
@@ -410,9 +411,8 @@ func (inst *inst) testProgram(command string, testTime time.Duration) error {
func FuzzerCmd(fuzzer, executor, name, OS, arch, fwdAddr, sandbox string, procs, verbosity int,
cover, debug, test, runtest bool) string {
osArg := ""
- switch OS {
- case "akaros", "fuchsia":
- // Only akaros needs OS, because the rest assume host OS.
+ if targets.Get(OS, arch).HostFuzzer {
+ // Only these OSes need the flag, 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
@@ -442,8 +442,7 @@ func ExecprogCmd(execprog, executor, OS, arch, sandbox string, repeat, threaded,
repeatCount = 0
}
osArg := ""
- switch OS {
- case "akaros", "fuchsia":
+ if targets.Get(OS, arch).HostFuzzer {
osArg = " -os=" + OS
}
return fmt.Sprintf("%v -executor=%v -arch=%v%v -sandbox=%v"+
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go
index 34b4ce2d0..cd3d6b02e 100644
--- a/pkg/ipc/ipc.go
+++ b/pkg/ipc/ipc.go
@@ -19,6 +19,7 @@ import (
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/pkg/signal"
"github.com/google/syzkaller/prog"
+ "github.com/google/syzkaller/sys/targets"
)
// Configuration flags for Config.Flags.
@@ -264,9 +265,8 @@ func (env *Env) Exec(opts *ExecOpts, p *prog.Prog) (output []byte, info *ProgInf
atomic.AddUint64(&env.StatExecs, 1)
if env.cmd == nil {
- switch p.Target.OS {
- case "akaros", "fuchsia":
- // On akaros executor is actually ssh,
+ if targets.Get(p.Target.OS, p.Target.Arch).HostFuzzer {
+ // The executor is actually ssh,
// starting them too frequently leads to timeouts.
<-rateLimit.C
}