aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/subsystem
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/subsystem')
-rw-r--r--pkg/subsystem/extractor.go19
-rw-r--r--pkg/subsystem/extractor_test.go15
2 files changed, 23 insertions, 11 deletions
diff --git a/pkg/subsystem/extractor.go b/pkg/subsystem/extractor.go
index 075c8079d..1f635c7b3 100644
--- a/pkg/subsystem/extractor.go
+++ b/pkg/subsystem/extractor.go
@@ -28,12 +28,27 @@ func MakeExtractor(list []*Subsystem) *Extractor {
func (e *Extractor) Extract(crashes []*Crash) []*Subsystem {
// First put all subsystems to the same list.
subsystems := []*Subsystem{}
+ reproCount := 0
for _, crash := range crashes {
if crash.GuiltyPath != "" {
subsystems = append(subsystems, e.raw.FromPath(crash.GuiltyPath)...)
}
- if len(crash.SyzRepro) > 0 {
- subsystems = append(subsystems, e.raw.FromProg(crash.SyzRepro)...)
+ if len(crash.SyzRepro) != 0 {
+ reproCount++
+ }
+ }
+
+ // If all reproducers hint at the same subsystem, take it as well.
+ reproSubsystems := map[*Subsystem]int{}
+ for _, crash := range crashes {
+ if len(crash.SyzRepro) == 0 {
+ continue
+ }
+ for _, subsystem := range e.raw.FromProg(crash.SyzRepro) {
+ reproSubsystems[subsystem]++
+ if reproSubsystems[subsystem] == reproCount {
+ subsystems = append(subsystems, subsystem)
+ }
}
}
diff --git a/pkg/subsystem/extractor_test.go b/pkg/subsystem/extractor_test.go
index c2d165973..a78509e0f 100644
--- a/pkg/subsystem/extractor_test.go
+++ b/pkg/subsystem/extractor_test.go
@@ -13,7 +13,7 @@ import (
func TestExtractor(t *testing.T) {
// Objects used in tests.
fsPath := "fs/"
- extProg, nfsProg := []byte("ext prog"), []byte("nfs prog")
+ extProg, nfsProg, extNfsProg := []byte("ext"), []byte("nfs"), []byte("ext nfs")
fs := &Subsystem{Name: "fs"}
ext := &Subsystem{Name: "ext", Parents: []*Subsystem{fs}}
nfs := &Subsystem{Name: "nfs", Parents: []*Subsystem{fs}}
@@ -46,7 +46,7 @@ func TestExtractor(t *testing.T) {
want: []*Subsystem{ext},
},
{
- name: `Two equally present children`,
+ name: `Reproducers hint at different subsystems`,
crashes: []*Crash{
{
GuiltyPath: fsPath,
@@ -60,10 +60,10 @@ func TestExtractor(t *testing.T) {
SyzRepro: nfsProg,
},
},
- want: []*Subsystem{nfs, ext},
+ want: []*Subsystem{fs},
},
{
- name: `One child is more present than another`,
+ name: `One subsystem from reproducers is irrelevant`,
crashes: []*Crash{
{
GuiltyPath: fsPath,
@@ -74,11 +74,7 @@ func TestExtractor(t *testing.T) {
},
{
GuiltyPath: fsPath,
- SyzRepro: nfsProg,
- },
- {
- GuiltyPath: fsPath,
- SyzRepro: extProg,
+ SyzRepro: extNfsProg,
},
},
want: []*Subsystem{ext},
@@ -92,6 +88,7 @@ func TestExtractor(t *testing.T) {
perProg: []progSubsystems{
{extProg, []*Subsystem{ext}},
{nfsProg, []*Subsystem{nfs}},
+ {extNfsProg, []*Subsystem{ext, nfs}},
},
},
}