From fc067f05bce8156101e90f93fe87e702114b863f Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 28 Mar 2023 15:03:50 +0200 Subject: pkg/subsystem: disambiguate subsystems by reproducers There are some minor subsystems (e.g. PAGE CACHE in Linux) that are parts of several big subsystems. At the same time, a reproducer can clearly disambiguate such case. If subsystems from reproducers and subsystems from guilty files intersect, only proceed with the results of the intersection. --- pkg/subsystem/extractor_test.go | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'pkg/subsystem/extractor_test.go') diff --git a/pkg/subsystem/extractor_test.go b/pkg/subsystem/extractor_test.go index a78509e0f..ec725a556 100644 --- a/pkg/subsystem/extractor_test.go +++ b/pkg/subsystem/extractor_test.go @@ -12,11 +12,13 @@ import ( func TestExtractor(t *testing.T) { // Objects used in tests. - fsPath := "fs/" + fsPath, mmFsPath := "fs/", "mm/fs.c" extProg, nfsProg, extNfsProg := []byte("ext"), []byte("nfs"), []byte("ext nfs") - fs := &Subsystem{Name: "fs"} + all := &Subsystem{Name: "fs"} + fs := &Subsystem{Name: "fs", Parents: []*Subsystem{all}} ext := &Subsystem{Name: "ext", Parents: []*Subsystem{fs}} nfs := &Subsystem{Name: "nfs", Parents: []*Subsystem{fs}} + mm := &Subsystem{Name: "mm", Parents: []*Subsystem{all}} // Tests themselves. tests := []struct { name string @@ -79,11 +81,33 @@ func TestExtractor(t *testing.T) { }, want: []*Subsystem{ext}, }, + { + name: `Reproducer supporting one of guilty paths`, + crashes: []*Crash{ + // The guilty paths correspond both to mm and fs. + { + GuiltyPath: mmFsPath, + }, + { + GuiltyPath: mmFsPath, + }, + { + GuiltyPath: mmFsPath, + }, + { + // But one reproducer points clearly to fs. + GuiltyPath: mmFsPath, + SyzRepro: extProg, + }, + }, + want: []*Subsystem{ext}, + }, } extractor := &Extractor{ raw: &testRawExtractor{ perPath: map[string][]*Subsystem{ - fsPath: {fs}, + fsPath: {fs}, + mmFsPath: {mm, fs}, }, perProg: []progSubsystems{ {extProg, []*Subsystem{ext}}, -- cgit mrf-deployment