From b0131d4eefe908aef51ea88be98dc8a926023371 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 20 Nov 2015 19:58:27 +0100 Subject: [PATCH] manager: add support for suppressions There are always some known bugs... --- manager/main.go | 18 ++++++++++++++++++ vm/qemu/qemu.go | 20 ++++++++++++++------ vm/vm.go | 2 ++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/manager/main.go b/manager/main.go index b539e1f5..c6766176 100644 --- a/manager/main.go +++ b/manager/main.go @@ -10,6 +10,7 @@ import ( "fmt" "io/ioutil" "log" + "regexp" "strings" "github.com/google/syzkaller/sys" @@ -37,6 +38,7 @@ type Config struct { Params map[string]interface{} Enable_Syscalls []string Disable_Syscalls []string + Suppressions []string } func main() { @@ -62,6 +64,22 @@ func main() { EnabledSyscalls: enabledSyscalls, NoCover: cfg.Nocover, } + + // Add some builtin suppressions. + cfg.Suppressions = append(cfg.Suppressions, []string{ + "panic: failed to start executor binary", + "panic: executor failed: pthread_create failed", + "panic: failed to create temp dir", + "Out of memory: Kill process .* \\(syzkaller_fuzze\\)", + }...) + for _, s := range cfg.Suppressions { + re, err := regexp.Compile(s) + if err != nil { + fatalf("failed to compile suppression '%v': %v", s, err) + } + vmCfg.Suppressions = append(vmCfg.Suppressions, re) + } + var instances []vm.Instance for i := 0; i < cfg.Count; i++ { inst, err := vm.Create(cfg.Type, vmCfg, i) diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index bcd1f3e5..be62c343 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -34,7 +34,7 @@ type qemu struct { crashdir string callsFlag string id int - mgrPort int + cfg *vm.Config } type params struct { @@ -92,7 +92,7 @@ func ctor(cfg *vm.Config, index int) (vm.Instance, error) { workdir: workdir, crashdir: crashdir, id: index, - mgrPort: cfg.ManagerPort, + cfg: cfg, } if cfg.EnabledSyscalls != "" { @@ -147,7 +147,7 @@ func (q *qemu) Run() { log: logf, rpipe: rpipe, wpipe: wpipe, - mgrPort: q.mgrPort, + cfg: q.cfg, cmds: make(map[*Command]bool), } inst.Run() @@ -167,7 +167,7 @@ type Instance struct { log *os.File rpipe *os.File wpipe *os.File - mgrPort int + cfg *vm.Config cmds map[*Command]bool qemu *Command } @@ -273,7 +273,7 @@ func (inst *Instance) Run() { // Run the binary. cmd := inst.CreateSSHCommand(fmt.Sprintf("/syzkaller_fuzzer -name %v -executor /syzkaller_executor -manager %v:%v %v", - inst.name, hostAddr, inst.mgrPort, inst.callsFlag)) + inst.name, hostAddr, inst.cfg.ManagerPort, inst.callsFlag)) deadline := start.Add(time.Hour) lastOutput := time.Now() @@ -350,7 +350,15 @@ func (inst *Instance) Run() { } func (inst *Instance) SaveCrasher(output []byte) { - ioutil.WriteFile(filepath.Join(inst.crashdir, fmt.Sprintf("crash%v-%v", inst.id, time.Now().UnixNano())), output, 0660) + for _, re := range inst.cfg.Suppressions { + if re.Match(output) { + log.Printf("qemu/%v: suppressing '%v'", inst.id, re.String()) + return + } + } + filename := fmt.Sprintf("crash%v-%v", inst.id, time.Now().UnixNano()) + log.Printf("qemu/%v: saving crash to %v", inst.id, filename) + ioutil.WriteFile(filepath.Join(inst.crashdir, filename), output, 0660) } func (inst *Instance) Shutdown() { diff --git a/vm/vm.go b/vm/vm.go index c49d5b75..e6430ec4 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -5,6 +5,7 @@ package vm import ( "fmt" + "regexp" ) type Instance interface { @@ -16,6 +17,7 @@ type Config struct { ManagerPort int Params []byte EnabledSyscalls string + Suppressions []*regexp.Regexp NoCover bool }