From f4470a7b5efeb021c66c8fb38656bcb2b1597974 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 25 Nov 2022 11:45:46 +0100 Subject: tools/syz-testbed: consider the resulting bug titles It's more correct to evaluate whether we managed to reproduce the original bug rather than just any bug. Retrieve the title information from syz-repro and pretent that the reproduction failed if the title does not match. --- tools/syz-testbed/instance.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tools/syz-testbed/instance.go') diff --git a/tools/syz-testbed/instance.go b/tools/syz-testbed/instance.go index f3a4c0bc6..5c7718c4f 100644 --- a/tools/syz-testbed/instance.go +++ b/tools/syz-testbed/instance.go @@ -5,9 +5,11 @@ package main import ( "fmt" + "io/ioutil" "log" "os" "path/filepath" + "strings" "time" "github.com/google/syzkaller/pkg/config" @@ -194,16 +196,26 @@ type SyzReproInstance struct { Input *SyzReproInput ReproFile string CReproFile string - // TODO: we also want to extract source and new bug titles + TitleFile string } func (inst *SyzReproInstance) FetchResult() (RunResult, error) { - return &SyzReproResult{ + result := &SyzReproResult{ Input: inst.Input, ReproFound: osutil.IsExist(inst.ReproFile), CReproFound: osutil.IsExist(inst.CReproFile), Duration: inst.Uptime(), - }, nil + } + outTitle, _ := ioutil.ReadFile(inst.TitleFile) + if outTitle != nil { + result.ReproTitle = strings.TrimSpace(string(outTitle)) + if result.ReproTitle != inst.Input.origTitle { + // If we found a different bug, treat the reproduction as unsuccessful. + result.ReproFound = false + result.CReproFound = false + } + } + return result, nil } func (t *SyzReproTarget) newSyzReproInstance(slotName, uniqName string, input *SyzReproInput, @@ -216,6 +228,7 @@ func (t *SyzReproTarget) newSyzReproInstance(slotName, uniqName string, input *S reproFile := filepath.Join(folder, "repro.txt") cReproFile := filepath.Join(folder, "crepro.txt") + titleFile := filepath.Join(folder, "title.txt") newExecLog := filepath.Join(folder, "execution-log.txt") err = osutil.CopyFile(input.Path, newExecLog) if err != nil { @@ -230,6 +243,7 @@ func (t *SyzReproTarget) newSyzReproInstance(slotName, uniqName string, input *S "-config", common.CfgFile, "-output", reproFile, "-crepro", cReproFile, + "-title", titleFile, newExecLog, }, stopChannel: make(chan bool, 1), @@ -238,5 +252,6 @@ func (t *SyzReproTarget) newSyzReproInstance(slotName, uniqName string, input *S Input: input, ReproFile: reproFile, CReproFile: cReproFile, + TitleFile: titleFile, }, nil } -- cgit mrf-deployment