Skip to content

Commit 48efbb0

Browse files
committed
vm/qemu: additional check for crashes only in Diagnose
1 parent ef766cd commit 48efbb0

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

vm/qemu/qemu.go

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/google/syzkaller/pkg/log"
2424
"github.com/google/syzkaller/pkg/osutil"
2525
"github.com/google/syzkaller/pkg/report"
26+
"github.com/google/syzkaller/pkg/report/crash"
2627
"github.com/google/syzkaller/sys/targets"
2728
"github.com/google/syzkaller/vm/vmimpl"
2829
)
@@ -734,8 +735,11 @@ func (inst *instance) Diagnose(rep *report.Report) ([]byte, bool) {
734735
return output, wait
735736
}
736737
}
737-
// TODO: we don't need registers on all reports. Probably only relevant for "crashes"
738-
// (NULL derefs, paging faults, etc), but is not useful for WARNING/BUG/HANG (?).
738+
739+
if !needsRegisterInfo(rep) {
740+
return nil, false
741+
}
742+
739743
ret := []byte(fmt.Sprintf("%s Registers:\n", time.Now().Format("15:04:05 ")))
740744
for cpu := 0; cpu < inst.cfg.CPU; cpu++ {
741745
regs, err := inst.hmp("info registers", cpu)
@@ -750,6 +754,33 @@ func (inst *instance) Diagnose(rep *report.Report) ([]byte, bool) {
750754
return ret, false
751755
}
752756

757+
func needsRegisterInfo(rep *report.Report) bool {
758+
// Do not collect register dump for the listed below report types.
759+
// By default collect as crash (for unknown types too).
760+
switch rep.Type {
761+
case crash.Warning,
762+
crash.AtomicSleep,
763+
crash.Hang,
764+
crash.DoS,
765+
crash.KCSANAssert,
766+
crash.KCSANDataRace,
767+
crash.KCSANUnknown,
768+
crash.KMSANInfoLeak,
769+
crash.KMSANUninitValue,
770+
crash.KMSANUnknown,
771+
crash.KMSANUseAfterFreeRead,
772+
crash.LockdepBug,
773+
crash.MemoryLeak,
774+
crash.RefcountWARNING,
775+
crash.LostConnection,
776+
crash.SyzFailure,
777+
crash.UnexpectedReboot:
778+
return false
779+
default:
780+
return true
781+
}
782+
}
783+
753784
func (inst *instance) ssh(args ...string) ([]byte, error) {
754785
return osutil.RunCmd(time.Minute*inst.timeouts.Scale, "", "ssh", inst.sshArgs(args...)...)
755786
}

0 commit comments

Comments
 (0)