From 07bfe8a540418c37449ef29dfc84ccf4d15ea0e0 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Mon, 30 Nov 2020 19:50:15 +0300 Subject: tools/syz-crush: improve the output Currently syz-crush saves the results in the syzkaller workdir. If you run this tool multiple times, you may lose the connection between your reproducers and the crash reports saved in workdir. Let's improve storeCrash(): 1. print the sequence number of the saved crash, 2. report about the errors during crash saving, 3. copy the reproducer to the workdir as well. Signed-off-by: Alexander Popov --- tools/syz-crush/crush.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/syz-crush/crush.go b/tools/syz-crush/crush.go index a20c827e5..2ebb27fd9 100644 --- a/tools/syz-crush/crush.go +++ b/tools/syz-crush/crush.go @@ -140,18 +140,28 @@ func storeCrash(cfg *mgrconfig.Config, rep *report.Report) { id := hash.String([]byte(rep.Title)) dir := filepath.Join(cfg.Workdir, "crashes", id) osutil.MkdirAll(dir) - log.Printf("saving crash %v to %v", rep.Title, dir) + + index := 0 + for ; osutil.IsExist(filepath.Join(dir, fmt.Sprintf("log%v", index))); index++ { + } + log.Printf("saving crash '%v' with index %v in %v", rep.Title, index, dir) if err := osutil.WriteFile(filepath.Join(dir, "description"), []byte(rep.Title+"\n")); err != nil { log.Printf("failed to write crash description: %v", err) } - index := 0 - for ; osutil.IsExist(filepath.Join(dir, fmt.Sprintf("log%v", index))); index++ { + if err := osutil.WriteFile(filepath.Join(dir, fmt.Sprintf("log%v", index)), rep.Output); err != nil { + log.Printf("failed to write crash log: %v", err) + } + if err := osutil.WriteFile(filepath.Join(dir, fmt.Sprintf("tag%v", index)), []byte(cfg.Tag)); err != nil { + log.Printf("failed to write crash tag: %v", err) } - osutil.WriteFile(filepath.Join(dir, fmt.Sprintf("log%v", index)), rep.Output) - osutil.WriteFile(filepath.Join(dir, fmt.Sprintf("tag%v", index)), []byte(cfg.Tag)) if len(rep.Report) > 0 { - osutil.WriteFile(filepath.Join(dir, fmt.Sprintf("report%v", index)), rep.Report) + if err := osutil.WriteFile(filepath.Join(dir, fmt.Sprintf("report%v", index)), rep.Report); err != nil { + log.Printf("failed to write crash report: %v", err) + } + } + if err := osutil.CopyFile(flag.Args()[0], filepath.Join(dir, fmt.Sprintf("reproducer%v", index))); err != nil { + log.Printf("failed to write crash reproducer: %v", err) } } -- cgit mrf-deployment