From c705ea526250b70e362704dc91d38eb1cd59fdc8 Mon Sep 17 00:00:00 2001 From: Jouni Hogander Date: Thu, 19 Nov 2020 17:09:11 +0200 Subject: tools/syz-bisect: give kernel/syzkaller commit as arguments --- tools/syz-bisect/bisect.go | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/tools/syz-bisect/bisect.go b/tools/syz-bisect/bisect.go index e0ada90cc..dbc92a47e 100644 --- a/tools/syz-bisect/bisect.go +++ b/tools/syz-bisect/bisect.go @@ -7,13 +7,13 @@ // // The tool requires a config file passed in -config flag, see Config type below for details, // and a directory with info about the crash passed in -crash flag). -// If -fix flag is specified, it does fix bisection. Otherwise it does cause bisection. +// If -fix flag is specified, it does fix bisection. Otherwise it does cause bisection. Also +// wanted syzkaller and kernel commits can be specified using -syzkaller_commit and +// -kernel_commit. HEAD is used if commits are not specified. // // 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) -// - syzkaller.commit: hash of syzkaller commit which was used to trigger the crash -// - kernel.commit: hash of kernel commit on which the crash was triggered package main import ( @@ -23,7 +23,6 @@ import ( "io/ioutil" "os" "path/filepath" - "strings" "github.com/google/syzkaller/pkg/bisect" "github.com/google/syzkaller/pkg/config" @@ -32,9 +31,11 @@ import ( ) var ( - flagConfig = flag.String("config", "", "bisect config file") - flagCrash = flag.String("crash", "", "dir with crash info") - flagFix = flag.Bool("fix", false, "search for crash fix") + flagConfig = flag.String("config", "", "bisect config file") + flagCrash = flag.String("crash", "", "dir with crash info") + flagFix = flag.Bool("fix", false, "search for crash fix") + flagKernelCommit = flag.String("kernel_commit", "", "original kernel commit") + flagSyzkallerCommit = flag.String("syzkaller_commit", "", "original syzkaller commit") ) type Config struct { @@ -93,17 +94,17 @@ func main() { Kernel: bisect.KernelConfig{ Repo: mycfg.KernelRepo, Branch: mycfg.KernelBranch, + Commit: *flagKernelCommit, Userspace: mycfg.Userspace, Sysctl: mycfg.Sysctl, Cmdline: mycfg.Cmdline, }, Syzkaller: bisect.SyzkallerConfig{ - Repo: mycfg.SyzkallerRepo, + Repo: mycfg.SyzkallerRepo, + Commit: *flagSyzkallerCommit, }, Manager: mgrcfg, } - loadString("syzkaller.commit", &cfg.Syzkaller.Commit) - loadString("kernel.commit", &cfg.Kernel.Commit) loadFile("", mycfg.KernelConfig, &cfg.Kernel.Config, true) loadFile("", mycfg.KernelBaselineConfig, &cfg.Kernel.BaselineConfig, false) loadFile(*flagCrash, "repro.prog", &cfg.Repro.Syz, false) @@ -121,15 +122,6 @@ func main() { } } -func loadString(file string, dst *string) { - data, err := ioutil.ReadFile(filepath.Join(*flagCrash, file)) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - *dst = strings.TrimSpace(string(data)) -} - func loadFile(path, file string, dst *[]byte, mandatory bool) { filename := filepath.Join(path, file) if !mandatory && !osutil.IsExist(filename) { -- cgit mrf-deployment