From e2f6c0c1b57a838c4c17cb3a2e07c6fbda41a7c6 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 13 Jul 2020 10:40:03 +0200 Subject: sys/targets: don't use HostFuzzer mode for test OS We set HostFuzzer for all test targets b/c in some contexts they needed the same special behavior as real HostFuzzer targets (e.g no checking enabled syscalls). However, in some other contexts they don't the same special behavior as real HostFuzzer targets. For example, pkg/ipc does rate limiting for HostFuzzer and pkg/runtest don't run C tests for HostFuzzer. Add special case for test targets in pkg/host, and don't set HostFuzzer for all test targets (keep it for one target for better coverage). --- pkg/host/features.go | 10 ++++++++-- pkg/host/syscalls.go | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/pkg/host/features.go b/pkg/host/features.go index 10137f2d9..800e3ea19 100644 --- a/pkg/host/features.go +++ b/pkg/host/features.go @@ -66,7 +66,7 @@ func Check(target *prog.Target) (*Features, error) { FeatureDevlinkPCI: {Name: "devlink PCI setup", Reason: unsupported}, FeatureUSBEmulation: {Name: "USB emulation", Reason: unsupported}, } - if targets.Get(target.OS, target.Arch).HostFuzzer { + if noHostChecks(target) { return res, nil } for n, check := range checkFeature { @@ -86,7 +86,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 { - if targets.Get(target.OS, target.Arch).HostFuzzer { + if noHostChecks(target) { return nil } args := strings.Split(executor, " ") @@ -110,3 +110,9 @@ func Setup(target *prog.Target, features *Features, featureFlags csource.Feature _, err := osutil.RunCmd(5*time.Minute, "", executor, args...) return err } + +func noHostChecks(target *prog.Target) bool { + // HostFuzzer targets can't run Go binaries on the targets, + // so we actually run on the host on another OS. The same for "test" OS. + return targets.Get(target.OS, target.Arch).HostFuzzer || target.OS == "test" +} diff --git a/pkg/host/syscalls.go b/pkg/host/syscalls.go index e322fc3b1..2abd3f16b 100644 --- a/pkg/host/syscalls.go +++ b/pkg/host/syscalls.go @@ -6,7 +6,6 @@ package host import ( "github.com/google/syzkaller/pkg/log" "github.com/google/syzkaller/prog" - "github.com/google/syzkaller/sys/targets" ) // DetectSupportedSyscalls returns list on supported and unsupported syscalls on the host. @@ -18,7 +17,7 @@ func DetectSupportedSyscalls(target *prog.Target, sandbox string) ( unsupported := make(map[*prog.Syscall]string) const disabledAttribute = "has disabled attribute in descriptions" // These do not have own host and parasitize on some other OS. - if targets.Get(target.OS, target.Arch).HostFuzzer { + if noHostChecks(target) { for _, c := range target.Syscalls { if c.Attrs.Disabled { unsupported[c] = disabledAttribute -- cgit mrf-deployment