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"
"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)

View File

@ -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() {

View File

@ -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
}