aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-04-01 13:16:03 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-04-29 17:16:33 +0200
commit2d51d57a71659b063ddcb21cc50845d05d39708b (patch)
tree6662e29b20177356ebbc0a4658890e43c39e1e78 /tools
parent33d1aba90b07c4319e1617be24f6f6dfd1b71d5e (diff)
all: run strace on each found reproducer
If `strace_bin` is specified, syzkaller will invoke a reproducer with it and save the output. This should help in debugging. If syz-manager is attached to a dashboard, upload the strace-powered output and report.
Diffstat (limited to 'tools')
-rw-r--r--tools/syz-crush/crush.go7
-rw-r--r--tools/syz-repro/repro.go18
2 files changed, 25 insertions, 0 deletions
diff --git a/tools/syz-crush/crush.go b/tools/syz-crush/crush.go
index 36424c61a..a88041a37 100644
--- a/tools/syz-crush/crush.go
+++ b/tools/syz-crush/crush.go
@@ -31,6 +31,7 @@ var (
flagDebug = flag.Bool("debug", false, "dump all VM output to console")
flagRestartTime = flag.Duration("restart_time", 0, "how long to run the test")
flagInfinite = flag.Bool("infinite", true, "by default test is run for ever, -infinite=false to stop on crash")
+ flagStrace = flag.Bool("strace", false, "run under strace (binary must be set in the config file")
)
type FileType int
@@ -59,6 +60,9 @@ func main() {
} else {
log.Printf("running until crash is found or till %v", *flagRestartTime)
}
+ if *flagStrace && cfg.StraceBin == "" {
+ log.Fatalf("strace_bin must not be empty in order to run with -strace")
+ }
vmPool, err := vm.Create(cfg, *flagDebug)
if err != nil {
@@ -160,6 +164,9 @@ func runInstance(cfg *mgrconfig.Config, reporter *report.Reporter,
optArgs := &instance.OptionalConfig{
ExitCondition: vm.ExitTimeout,
}
+ if *flagStrace {
+ optArgs.StraceBin = cfg.StraceBin
+ }
var err error
inst, err := instance.CreateExecProgInstance(vmPool, index, cfg, reporter, optArgs)
if err != nil {
diff --git a/tools/syz-repro/repro.go b/tools/syz-repro/repro.go
index 6622b8203..247cc11cd 100644
--- a/tools/syz-repro/repro.go
+++ b/tools/syz-repro/repro.go
@@ -25,6 +25,7 @@ var (
flagDebug = flag.Bool("debug", false, "print debug output")
flagOutput = flag.String("output", filepath.Join(".", "repro.txt"), "output description file (output.txt)")
flagCRepro = flag.String("crepro", filepath.Join(".", "repro.c"), "output c file (repro.c)")
+ flagStrace = flag.String("strace", "", "output strace log (strace_bin must be set)")
)
func main() {
@@ -104,4 +105,21 @@ func main() {
log.Logf(0, "failed to write C repro to file: %v", err)
}
}
+ if *flagStrace != "" {
+ result := repro.RunStrace(res, cfg, reporter, vmPool, vmIndexes[0])
+ if result.Error != nil {
+ log.Logf(0, "failed to run strace: %v", result.Error)
+ } else {
+ if result.Report != nil {
+ log.Logf(0, "under strace repro crashed with title: %s", result.Report.Title)
+ } else {
+ log.Logf(0, "repro didn't crash under strace")
+ }
+ if err := osutil.WriteFile(*flagStrace, result.Output); err == nil {
+ fmt.Printf("C file saved to %s\n", *flagStrace)
+ } else {
+ log.Logf(0, "failed to write strace output to file: %v", err)
+ }
+ }
+ }
}