From ad871703d4fcd9ed84544dd6f5c4221aa5df5feb Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 31 Jan 2023 13:38:10 +0100 Subject: pkg/subsystem: extract subsystems from a crash list For now, let's use a straightforward approach: 1) Extract all subsystems for each guilty path and syz reproducer. 2) If there are both parents and children in the list, remove parents. 3) Count the remaining subsystems. 4) Pick the ones that appear most often. --- pkg/subsystem/entity/entities.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'pkg/subsystem/entity') diff --git a/pkg/subsystem/entity/entities.go b/pkg/subsystem/entity/entities.go index bca218ebe..9d1d8e5a5 100644 --- a/pkg/subsystem/entity/entities.go +++ b/pkg/subsystem/entity/entities.go @@ -12,6 +12,23 @@ type Subsystem struct { Parents []*Subsystem } +// ReachableParents returns the set of subsystems reachable from the current one. +func (subsystem *Subsystem) ReachableParents() map[*Subsystem]struct{} { + ret := make(map[*Subsystem]struct{}) + var dfs func(node *Subsystem) + dfs = func(node *Subsystem) { + if _, visited := ret[node]; visited { + return + } + for _, p := range node.Parents { + ret[p] = struct{}{} + dfs(p) + } + } + dfs(subsystem) + return ret +} + // PathRule describes the part of the directory tree belonging to a single subsystem. type PathRule struct { IncludeRegexp string -- cgit mrf-deployment