From 78d50c1d18bbb8b2d22e72300ef316e0b067e61d Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 29 Nov 2020 12:09:22 +0100 Subject: pkg/ipc: remove Config.Timeout It's not used for anything useful and will conflict with automatic timeout tuning. --- pkg/ipc/ipc.go | 38 ++++++++++---------------------------- pkg/ipc/ipc_test.go | 3 --- pkg/ipc/ipcconfig/ipcconfig.go | 2 -- 3 files changed, 10 insertions(+), 33 deletions(-) (limited to 'pkg') diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index 06b39af9d..19bc89183 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -72,9 +72,6 @@ type Config struct { // Flags are configuation flags, defined above. Flags EnvFlags - - // Timeout is the execution timeout for a single program. - Timeout time.Duration } type CallFlags uint32 @@ -540,10 +537,19 @@ func makeCommand(pid int, bin []string, config *Config, inFile, outFile *os.File } dir = osutil.Abs(dir) + // Executor protects against most hangs, so we use quite large timeout here. + // Executor can be slow due to global locks in namespaces and other things, + // so let's better wait than report false misleading crashes. + timeout := time.Minute + if !config.UseForkServer { + // If there is no fork server, executor does not have internal timeout. + timeout = 5 * time.Second + } + c := &command{ pid: pid, config: config, - timeout: sanitizeTimeout(config), + timeout: timeout, dir: dir, outmem: outmem, } @@ -809,27 +815,3 @@ func (c *command) exec(opts *ExecOpts, progData []byte) (output []byte, hanged b } return } - -func sanitizeTimeout(config *Config) time.Duration { - const ( - executorTimeout = 5 * time.Second - minTimeout = executorTimeout + 2*time.Second - ) - timeout := config.Timeout - if timeout == 0 { - // Executor protects against most hangs, so we use quite large timeout here. - // Executor can be slow due to global locks in namespaces and other things, - // so let's better wait than report false misleading crashes. - timeout = time.Minute - if !config.UseForkServer { - // If there is no fork server, executor does not have internal timeout. - timeout = executorTimeout - } - } - // IPC timeout must be larger then executor timeout. - // Otherwise IPC will kill parent executor but leave child executor alive. - if config.UseForkServer && timeout < minTimeout { - timeout = minTimeout - } - return timeout -} diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go index e7c9aa0f8..b5c963392 100644 --- a/pkg/ipc/ipc_test.go +++ b/pkg/ipc/ipc_test.go @@ -21,8 +21,6 @@ import ( "github.com/google/syzkaller/sys/targets" ) -const timeout = 10 * time.Second - func buildExecutor(t *testing.T, target *prog.Target) string { src := filepath.FromSlash("../../executor/executor.cc") bin, err := csource.BuildFile(target, src) @@ -96,7 +94,6 @@ func TestExecute(t *testing.T) { Executor: bin, UseShmem: useShmem, UseForkServer: useForkServer, - Timeout: timeout, } env, err := MakeEnv(cfg, 0) if err != nil { diff --git a/pkg/ipc/ipcconfig/ipcconfig.go b/pkg/ipc/ipcconfig/ipcconfig.go index 42b4d36d5..a99cbdadc 100644 --- a/pkg/ipc/ipcconfig/ipcconfig.go +++ b/pkg/ipc/ipcconfig/ipcconfig.go @@ -18,13 +18,11 @@ var ( flagSignal = flag.Bool("cover", false, "collect feedback signals (coverage)") flagSandbox = flag.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace/android)") flagDebug = flag.Bool("debug", false, "debug output from executor") - flagTimeout = flag.Duration("timeout", 0, "execution timeout") ) func Default(target *prog.Target) (*ipc.Config, *ipc.ExecOpts, error) { c := &ipc.Config{ Executor: *flagExecutor, - Timeout: *flagTimeout, } if *flagSignal { c.Flags |= ipc.FlagSignal -- cgit mrf-deployment