Example #1
0
func (mgr *Manager) saveCrasher(vmCfg *vm.Config, desc string, text, output []byte) {
	if atomic.LoadUint32(&mgr.shutdown) != 0 {
		// qemu crashes with "qemu: terminating on signal 2",
		// which we detect as "lost connection".
		return
	}
	for _, re := range mgr.suppressions {
		if re.Match(output) {
			Logf(1, "%v: suppressing '%v' with '%v'", vmCfg.Name, desc, re.String())
			mgr.mu.Lock()
			mgr.stats["suppressed"]++
			mgr.mu.Unlock()
			return
		}
	}

	Logf(0, "%v: crash: %v", vmCfg.Name, desc)
	mgr.mu.Lock()
	mgr.stats["crashes"]++
	mgr.mu.Unlock()

	h := hash([]byte(desc))
	id := hex.EncodeToString(h[:])
	dir := filepath.Join(mgr.crashdir, id)
	os.MkdirAll(dir, 0700)
	if err := ioutil.WriteFile(filepath.Join(dir, "description"), []byte(desc+"\n"), 0660); err != nil {
		Logf(0, "failed to write crash: %v", err)
	}
	// Save up to 100 reports. If we already have 100, overwrite the oldest one.
	// Newer reports are generally more useful. Overwriting is also needed
	// to be able to understand if a particular bug still happens or already fixed.
	oldestI := 0
	var oldestTime time.Time
	for i := 0; i < 100; i++ {
		info, err := os.Stat(filepath.Join(dir, fmt.Sprintf("log%v", i)))
		if err != nil {
			oldestI = i
			break
		}
		if oldestTime.IsZero() || info.ModTime().Before(oldestTime) {
			oldestI = i
			oldestTime = info.ModTime()
		}
	}
	ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("log%v", oldestI)), output, 0660)
	if len(mgr.cfg.Tag) > 0 {
		ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("tag%v", oldestI)), []byte(mgr.cfg.Tag), 0660)
	}
	if len(text) > 0 {
		symbolized, err := report.Symbolize(mgr.cfg.Vmlinux, text)
		if err != nil {
			Logf(0, "failed to symbolize crash: %v", err)
		} else {
			text = symbolized
		}
		ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("report%v", oldestI)), []byte(text), 0660)
	}
}
Example #2
0
func (mgr *Manager) saveCrash(crash *Crash) {
	Logf(0, "%v: crash: %v", crash.vmName, crash.desc)
	mgr.mu.Lock()
	mgr.stats["crashes"]++
	mgr.mu.Unlock()

	sig := hash.Hash([]byte(crash.desc))
	id := sig.String()
	dir := filepath.Join(mgr.crashdir, id)
	os.MkdirAll(dir, 0700)
	if err := ioutil.WriteFile(filepath.Join(dir, "description"), []byte(crash.desc+"\n"), 0660); err != nil {
		Logf(0, "failed to write crash: %v", err)
	}
	// Save up to 100 reports. If we already have 100, overwrite the oldest one.
	// Newer reports are generally more useful. Overwriting is also needed
	// to be able to understand if a particular bug still happens or already fixed.
	oldestI := 0
	var oldestTime time.Time
	for i := 0; i < 100; i++ {
		info, err := os.Stat(filepath.Join(dir, fmt.Sprintf("log%v", i)))
		if err != nil {
			oldestI = i
			break
		}
		if oldestTime.IsZero() || info.ModTime().Before(oldestTime) {
			oldestI = i
			oldestTime = info.ModTime()
		}
	}
	ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("log%v", oldestI)), crash.output, 0660)
	if len(mgr.cfg.Tag) > 0 {
		ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("tag%v", oldestI)), []byte(mgr.cfg.Tag), 0660)
	}
	if len(crash.text) > 0 {
		symbolized, err := report.Symbolize(mgr.cfg.Vmlinux, crash.text)
		if err != nil {
			Logf(0, "failed to symbolize crash: %v", err)
		} else {
			crash.text = symbolized
		}
		ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("report%v", oldestI)), []byte(crash.text), 0660)
	}
}
Example #3
0
func main() {
	flag.Parse()
	if len(flag.Args()) != 1 {
		fmt.Fprintf(os.Stderr, "usage: syz-symbolize [flags] kernel_log_file\n")
		flag.PrintDefaults()
		os.Exit(1)
	}
	text, err := ioutil.ReadFile(flag.Args()[0])
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to open input file: %v\n", err)
		os.Exit(1)
	}
	if _, parsed, _, _ := report.Parse(text, nil); len(parsed) != 0 {
		text = parsed
	}
	text, err = report.Symbolize(filepath.Join(*flagLinux, "vmlinux"), text)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to symbolize: %v\n", err)
		os.Exit(1)
	}
	os.Stdout.Write(text)
}
Example #4
0
func main() {
	if len(os.Args) != 3 {
		fmt.Fprintf(os.Stderr, "usage: syz-report vmlinux report (args %+v)\n", os.Args)
		os.Exit(1)
	}
	output, err := ioutil.ReadFile(os.Args[2])
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to read report file: %v\n", err)
		os.Exit(1)
	}
	desc, text, _, _ := report.Parse(output)
	if desc == "" {
		fmt.Fprintf(os.Stderr, "report file does not contain a crash\n")
		os.Exit(1)
	}
	symbolized, err := report.Symbolize(os.Args[1], text)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to symbolize report: %v\n", err)
	} else {
		text = symbolized
	}
	fmt.Printf("%v\n\n%s", desc, text)
}