diff options
| author | Jouni Hogander <jouni.hogander@unikie.com> | 2020-11-19 17:09:11 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-12-10 12:57:35 +0100 |
| commit | c705ea526250b70e362704dc91d38eb1cd59fdc8 (patch) | |
| tree | 4323e2d0a7904db99c9972e2260eb43b2e38f1aa | |
| parent | 1b96fc56ed8ba1be4feb10b1f9658d64a65f5d4b (diff) | |
tools/syz-bisect: give kernel/syzkaller commit as arguments
| -rw-r--r-- | tools/syz-bisect/bisect.go | 30 |
1 files 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) { |
