manager: add support for suppressions

There are always some known bugs...
This commit is contained in:
Dmitry Vyukov 2015-11-20 19:58:27 +01:00
parent 11b28f5166
commit b0131d4eef
3 changed files with 34 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
"regexp"
"strings" "strings"
"github.com/google/syzkaller/sys" "github.com/google/syzkaller/sys"
@ -37,6 +38,7 @@ type Config struct {
Params map[string]interface{} Params map[string]interface{}
Enable_Syscalls []string Enable_Syscalls []string
Disable_Syscalls []string Disable_Syscalls []string
Suppressions []string
} }
func main() { func main() {
@ -62,6 +64,22 @@ func main() {
EnabledSyscalls: enabledSyscalls, EnabledSyscalls: enabledSyscalls,
NoCover: cfg.Nocover, 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 var instances []vm.Instance
for i := 0; i < cfg.Count; i++ { for i := 0; i < cfg.Count; i++ {
inst, err := vm.Create(cfg.Type, vmCfg, i) inst, err := vm.Create(cfg.Type, vmCfg, i)

View File

@ -34,7 +34,7 @@ type qemu struct {
crashdir string crashdir string
callsFlag string callsFlag string
id int id int
mgrPort int cfg *vm.Config
} }
type params struct { type params struct {
@ -92,7 +92,7 @@ func ctor(cfg *vm.Config, index int) (vm.Instance, error) {
workdir: workdir, workdir: workdir,
crashdir: crashdir, crashdir: crashdir,
id: index, id: index,
mgrPort: cfg.ManagerPort, cfg: cfg,
} }
if cfg.EnabledSyscalls != "" { if cfg.EnabledSyscalls != "" {
@ -147,7 +147,7 @@ func (q *qemu) Run() {
log: logf, log: logf,
rpipe: rpipe, rpipe: rpipe,
wpipe: wpipe, wpipe: wpipe,
mgrPort: q.mgrPort, cfg: q.cfg,
cmds: make(map[*Command]bool), cmds: make(map[*Command]bool),
} }
inst.Run() inst.Run()
@ -167,7 +167,7 @@ type Instance struct {
log *os.File log *os.File
rpipe *os.File rpipe *os.File
wpipe *os.File wpipe *os.File
mgrPort int cfg *vm.Config
cmds map[*Command]bool cmds map[*Command]bool
qemu *Command qemu *Command
} }
@ -273,7 +273,7 @@ func (inst *Instance) Run() {
// Run the binary. // Run the binary.
cmd := inst.CreateSSHCommand(fmt.Sprintf("/syzkaller_fuzzer -name %v -executor /syzkaller_executor -manager %v:%v %v", 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) deadline := start.Add(time.Hour)
lastOutput := time.Now() lastOutput := time.Now()
@ -350,7 +350,15 @@ func (inst *Instance) Run() {
} }
func (inst *Instance) SaveCrasher(output []byte) { 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() { func (inst *Instance) Shutdown() {

View File

@ -5,6 +5,7 @@ package vm
import ( import (
"fmt" "fmt"
"regexp"
) )
type Instance interface { type Instance interface {
@ -16,6 +17,7 @@ type Config struct {
ManagerPort int ManagerPort int
Params []byte Params []byte
EnabledSyscalls string EnabledSyscalls string
Suppressions []*regexp.Regexp
NoCover bool NoCover bool
} }