From cbd0445ec3b0b184db66966d8a47e6b37d13692e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 25 Nov 2020 09:17:50 +0100 Subject: all: make timeouts configurable Add sys/targets.Timeouts struct that parametrizes timeouts throughout the system. The struct allows to control syscall/program/no output timeouts for OS/arch/VM/etc. See comment on the struct for more details. --- pkg/mgrconfig/load.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'pkg/mgrconfig') diff --git a/pkg/mgrconfig/load.go b/pkg/mgrconfig/load.go index a11de44be..9814987a7 100644 --- a/pkg/mgrconfig/load.go +++ b/pkg/mgrconfig/load.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "regexp" + "runtime" "strings" "github.com/google/syzkaller/pkg/config" @@ -34,6 +35,7 @@ type Derived struct { ExecutorBin string Syscalls []int + Timeouts targets.Timeouts } func LoadData(data []byte) (*Config, error) { @@ -171,9 +173,27 @@ func Complete(cfg *Config) error { if err != nil { return err } + cfg.initTimeouts() return nil } +func (cfg *Config) initTimeouts() { + slowdown := 1 + switch { + case cfg.Type == "qemu" && runtime.GOARCH != cfg.SysTarget.Arch && runtime.GOARCH != cfg.SysTarget.VMArch: + // Assuming qemu emulation. + // Quick tests of mmap syscall on arm64 show ~9x slowdown. + slowdown = 10 + case cfg.Type == "gvisor" && cfg.Cover && strings.Contains(cfg.Name, "-race"): + // Go coverage+race has insane slowdown of ~350x. We can't afford such large value, + // but a smaller value should be enough to finish at least some syscalls. + // Note: the name check is a hack. + slowdown = 10 + } + // Note: we could also consider heavy debug tools (KASAN/KMSAN/KCSAN/KMEMLEAK) if necessary. + cfg.Timeouts = cfg.SysTarget.Timeouts(slowdown) +} + func checkNonEmpty(fields ...string) error { for i := 0; i < len(fields); i += 2 { if fields[i] == "" { -- cgit mrf-deployment