aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-symbolize
diff options
context:
space:
mode:
authorJouni Högander <jouni.hogander@unikie.com>2020-03-04 11:35:51 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-04-03 11:01:08 +0200
commit5ed396e666c7826bed46f06c4db1409376691fed (patch)
tree148d472a652d47affdb5272248dfe772d5dfc8a2 /tools/syz-symbolize
parent9a5264054c4b27bb78e8fdad7526dfeb53ff4bbd (diff)
tools/syz-symbolize: Store crash report if outdir is given
We want to check if the original crash reproducer was generated is reproduced. We need to generate syzkaller style crash report on reproducer log and check if hash matches with the original hash. This patch adds outdir flags to syz-symbolize and stores crashes found from given log into it.
Diffstat (limited to 'tools/syz-symbolize')
-rw-r--r--tools/syz-symbolize/symbolize.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/syz-symbolize/symbolize.go b/tools/syz-symbolize/symbolize.go
index 5f88e68cd..299531ced 100644
--- a/tools/syz-symbolize/symbolize.go
+++ b/tools/syz-symbolize/symbolize.go
@@ -8,9 +8,12 @@ import (
"fmt"
"io/ioutil"
"os"
+ "path/filepath"
"runtime"
+ "github.com/google/syzkaller/pkg/hash"
"github.com/google/syzkaller/pkg/mgrconfig"
+ "github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/pkg/report"
)
@@ -19,6 +22,7 @@ var (
flagArch = flag.String("arch", runtime.GOARCH, "target arch")
flagKernelObj = flag.String("kernel_obj", ".", "path to kernel build/obj dir")
flagKernelSrc = flag.String("kernel_src", "", "path to kernel sources (defaults to kernel_obj)")
+ flagOutDir = flag.String("outdir", "", "output directory")
)
func main() {
@@ -49,6 +53,8 @@ func main() {
rep := reporter.Parse(text)
if rep == nil {
rep = &report.Report{Report: text}
+ } else if *flagOutDir != "" {
+ saveCrash(rep, *flagOutDir)
}
if err := reporter.Symbolize(rep); err != nil {
fmt.Fprintf(os.Stderr, "failed to symbolize report: %v\n", err)
@@ -60,3 +66,26 @@ func main() {
fmt.Printf("\n")
os.Stdout.Write(rep.Report)
}
+
+func saveCrash(rep *report.Report, path string) {
+ sig := hash.Hash([]byte(rep.Title))
+ id := sig.String()
+ dir := filepath.Join(path, id)
+ osutil.MkdirAll(dir)
+ if err := osutil.WriteFile(filepath.Join(dir, "description"), []byte(rep.Title+"\n")); err != nil {
+ fmt.Fprintf(os.Stderr, "failed to write description: %v", err)
+ os.Exit(1)
+ }
+
+ if err := osutil.WriteFile(filepath.Join(dir, "log"), rep.Output); err != nil {
+ fmt.Fprintf(os.Stderr, "failed to write log: %v", err)
+ os.Exit(1)
+ }
+
+ if len(rep.Report) > 0 {
+ if err := osutil.WriteFile(filepath.Join(dir, "report"), rep.Report); err != nil {
+ fmt.Fprintf(os.Stderr, "failed to write report: %v", err)
+ os.Exit(1)
+ }
+ }
+}