From e97786ae481ec832fb4477df20aeab0d96fe25a6 Mon Sep 17 00:00:00 2001 From: Jouni Hogander Date: Thu, 19 Nov 2020 14:56:00 +0200 Subject: tools/syz-bisect: store bisection results Store bisection results into given crashdir as fix.commit or cause.commit --- tools/syz-bisect/bisect.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/syz-bisect/bisect.go b/tools/syz-bisect/bisect.go index 3241ff469..1c8692700 100644 --- a/tools/syz-bisect/bisect.go +++ b/tools/syz-bisect/bisect.go @@ -14,6 +14,8 @@ // The crash dir should contain the following files: // - repro.cprog or repro.prog: reproducer for the crash // - repro.opts: syzkaller reproducer options (e.g. {"procs":1,"sandbox":"none",...}) (optional) +// +// The tool stores bisection result into cause.commit or fix.commit. package main import ( @@ -127,10 +129,13 @@ func main() { cfg.Kernel.Commit = vcs.HEAD } - if _, err := bisect.Run(cfg); err != nil { + result, err := bisect.Run(cfg) + if err != nil { fmt.Fprintf(os.Stderr, "bisection failed: %v\n", err) os.Exit(1) } + + saveResultCommits(result.Commits) } func loadFile(path, file string, dst *[]byte, mandatory bool) { @@ -145,3 +150,24 @@ func loadFile(path, file string, dst *[]byte, mandatory bool) { } *dst = data } + +func saveResultCommits(commits []*vcs.Commit) { + var result string + if len(commits) > 0 { + for _, commit := range commits { + result = result + commit.Hash + "\n" + } + } else if *flagFix { + result = "the crash still happens on HEAD\n" + } else { + result = "the crash already happened on the oldest tested release\n" + } + + var fileName string + if *flagFix { + fileName = filepath.Join(*flagCrash, "fix.commit") + } else { + fileName = filepath.Join(*flagCrash, "cause.commit") + } + osutil.WriteFile(fileName, []byte(result)) +} -- cgit mrf-deployment