aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-07-13 10:40:03 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-07-15 09:26:23 +0200
commite2f6c0c1b57a838c4c17cb3a2e07c6fbda41a7c6 (patch)
treea225d582b84de4f96ab663fe826316b3af868591 /pkg
parentf3bec699b60e09e7428029b500ac2ef9b6fde4d1 (diff)
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).
Diffstat (limited to 'pkg')
-rw-r--r--pkg/host/features.go10
-rw-r--r--pkg/host/syscalls.go3
2 files changed, 9 insertions, 4 deletions
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