diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-08-03 18:18:05 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-08-03 18:29:20 +0200 |
| commit | 649477b6a5ae651dbf3c731911b81edd8c9d5fb2 (patch) | |
| tree | dd4bd0eec2bcfba3afe2df19b27f11c1cd219701 /pkg | |
| parent | 6bfd4f09db1079ee95e0ee10f770e34499e9eeee (diff) | |
pkg/ipc: remove abort signal and buffer size
They were needed for intermediate gvisor support.
Now that we have end-to-end support for gvisor,
they are not needed anymore. Remove.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/ipc/ipc.go | 55 | ||||
| -rw-r--r-- | pkg/ipc/ipcconfig/ipcconfig.go | 24 | ||||
| -rw-r--r-- | pkg/osutil/osutil_fuchsia.go | 4 | ||||
| -rw-r--r-- | pkg/osutil/osutil_unix.go | 11 | ||||
| -rw-r--r-- | pkg/osutil/osutil_windows.go | 4 |
5 files changed, 23 insertions, 75 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index f1dda1e88..fbaf8962c 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -71,16 +71,6 @@ type Config struct { // Timeout is the execution timeout for a single program. Timeout time.Duration - - // AbortSignal is the signal to send to the executor in error conditions. - AbortSignal int - - // BufferSize is the size of the internal buffer for executor output. - BufferSize uint64 - - // RateLimit flag tells to start one executor at a time. - // Currently used only for akaros where executor is actually ssh. - RateLimit bool } type CallFlags uint32 @@ -215,6 +205,8 @@ func (env *Env) Close() error { } } +var rateLimit = time.NewTicker(1 * time.Second) + // Exec starts executor binary to execute program p and returns information about the execution: // output: process output // info: per-call info @@ -240,6 +232,11 @@ func (env *Env) Exec(opts *ExecOpts, p *prog.Prog) (output []byte, info []CallIn atomic.AddUint64(&env.StatExecs, 1) if env.cmd == nil { + if p.Target.OS == "akaros" { + // On akaros executor is actually ssh, + // starting them too frequently leads to timeouts. + <-rateLimit.C + } atomic.AddUint64(&env.StatRestarts, 1) env.cmd, err0 = makeCommand(env.pid, env.bin, env.config, env.inFile, env.outFile, env.out) if err0 != nil { @@ -462,13 +459,8 @@ type callReply struct { // signal/cover/comps follow } -var rateLimit = time.NewTicker(1 * time.Second) - -func makeCommand(pid int, bin []string, config *Config, inFile *os.File, outFile *os.File, - outmem []byte) (*command, error) { - if config.RateLimit { - <-rateLimit.C - } +func makeCommand(pid int, bin []string, config *Config, inFile, outFile *os.File, outmem []byte) ( + *command, error) { dir, err := ioutil.TempDir("./", "syzkaller-testdir") if err != nil { return nil, fmt.Errorf("failed to create temp dir: %v", err) @@ -538,10 +530,7 @@ func makeCommand(pid int, bin []string, config *Config, inFile *os.File, outFile cmd.Stderr = wp go func(c *command) { // Read out output in case executor constantly prints something. - bufSize := c.config.BufferSize - if bufSize == 0 { - bufSize = 128 << 10 - } + const bufSize = 128 << 10 output := make([]byte, bufSize) var size uint64 for { @@ -581,7 +570,7 @@ func makeCommand(pid int, bin []string, config *Config, inFile *os.File, outFile func (c *command) close() { if c.cmd != nil { - c.abort() + c.cmd.Process.Kill() c.wait() } osutil.UmountAll(c.dir) @@ -634,7 +623,7 @@ func (c *command) handshake() error { } func (c *command) handshakeError(err error) error { - c.abort() + c.cmd.Process.Kill() output := <-c.readDone err = fmt.Errorf("executor %v: %v\n%s", c.pid, err, output) c.wait() @@ -647,22 +636,6 @@ func (c *command) handshakeError(err error) error { return err } -// abort sends the abort signal to the command and then SIGKILL if wait doesn't return within 5s. -func (c *command) abort() { - if osutil.ProcessSignal(c.cmd.Process, c.config.AbortSignal) { - return - } - go func() { - t := time.NewTimer(5 * time.Second) - select { - case <-t.C: - c.cmd.Process.Kill() - case <-c.exited: - t.Stop() - } - }() -} - func (c *command) wait() error { err := c.cmd.Wait() select { @@ -706,7 +679,7 @@ func (c *command) exec(opts *ExecOpts, progData []byte) (output []byte, failed, t := time.NewTimer(c.timeout) select { case <-t.C: - c.abort() + c.cmd.Process.Kill() hang <- true case <-done: t.Stop() @@ -751,7 +724,7 @@ func (c *command) exec(opts *ExecOpts, progData []byte) (output []byte, failed, <-hang return } - c.abort() + c.cmd.Process.Kill() output = <-c.readDone if err := c.wait(); <-hang { hanged = true diff --git a/pkg/ipc/ipcconfig/ipcconfig.go b/pkg/ipc/ipcconfig/ipcconfig.go index 6f13ad137..7c74ea94d 100644 --- a/pkg/ipc/ipcconfig/ipcconfig.go +++ b/pkg/ipc/ipcconfig/ipcconfig.go @@ -13,25 +13,19 @@ import ( ) var ( - flagExecutor = flag.String("executor", "./syz-executor", "path to executor binary") - flagThreaded = flag.Bool("threaded", true, "use threaded mode in executor") - flagCollide = flag.Bool("collide", true, "collide syscalls to provoke data races") - flagSignal = flag.Bool("cover", false, "collect feedback signals (coverage)") - flagSandbox = flag.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace)") - flagDebug = flag.Bool("debug", false, "debug output from executor") - flagTimeout = flag.Duration("timeout", 0, "execution timeout") - flagAbortSignal = flag.Int("abort_signal", 0, "initial signal to send to executor"+ - " in error conditions; upgrades to SIGKILL if executor does not exit") - flagBufferSize = flag.Uint64("buffer_size", 0, "internal buffer size (in bytes) for executor output") + flagExecutor = flag.String("executor", "./syz-executor", "path to executor binary") + flagThreaded = flag.Bool("threaded", true, "use threaded mode in executor") + flagCollide = flag.Bool("collide", true, "collide syscalls to provoke data races") + flagSignal = flag.Bool("cover", false, "collect feedback signals (coverage)") + flagSandbox = flag.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace)") + 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, - AbortSignal: *flagAbortSignal, - BufferSize: *flagBufferSize, - RateLimit: target.OS == "akaros", + Executor: *flagExecutor, + Timeout: *flagTimeout, } if *flagSignal { c.Flags |= ipc.FlagSignal diff --git a/pkg/osutil/osutil_fuchsia.go b/pkg/osutil/osutil_fuchsia.go index e1cbe6046..c9fe585e9 100644 --- a/pkg/osutil/osutil_fuchsia.go +++ b/pkg/osutil/osutil_fuchsia.go @@ -30,10 +30,6 @@ func ProcessExitStatus(ps *os.ProcessState) int { return 0 } -func ProcessSignal(p *os.Process, sig int) bool { - return false -} - func prolongPipe(r, w *os.File) { } diff --git a/pkg/osutil/osutil_unix.go b/pkg/osutil/osutil_unix.go index 92c85d4c6..ad6886bc0 100644 --- a/pkg/osutil/osutil_unix.go +++ b/pkg/osutil/osutil_unix.go @@ -144,14 +144,3 @@ func CloseMemMappedFile(f *os.File, mem []byte) error { func ProcessExitStatus(ps *os.ProcessState) int { return ps.Sys().(syscall.WaitStatus).ExitStatus() } - -// ProcessSignal sends signal sig to the process, returns true if the process was killed. -// Again, this is here only because of fuchsia. -func ProcessSignal(p *os.Process, sig int) bool { - SIGKILL := int(syscall.SIGKILL) - if sig <= 0 || sig >= 32 { - sig = SIGKILL - } - p.Signal(syscall.Signal(sig)) - return sig == SIGKILL -} diff --git a/pkg/osutil/osutil_windows.go b/pkg/osutil/osutil_windows.go index 2d8569921..4c9918a3c 100644 --- a/pkg/osutil/osutil_windows.go +++ b/pkg/osutil/osutil_windows.go @@ -33,10 +33,6 @@ func ProcessExitStatus(ps *os.ProcessState) int { return ps.Sys().(syscall.WaitStatus).ExitStatus() } -func ProcessSignal(p *os.Process, sig int) bool { - return false -} - func Sandbox(cmd *exec.Cmd, user, net bool) error { return nil } |
