diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-02-10 12:14:36 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-02-10 14:34:44 +0100 |
| commit | 95871dcc45f6531b4c692ff892aad56bdd95e16f (patch) | |
| tree | 95c8ffe8b8a36b1dc9473cc3a07e7286595e0b2f /pkg/subsystem/linux/parents.go | |
| parent | 0ee9f5fa4e372b5a2da4ac27418e6c5bccbcaf7a (diff) | |
pkg/subsystem: restructure the package
Remove the entity and match subpackages.
Regenerate the linux.go file.
Diffstat (limited to 'pkg/subsystem/linux/parents.go')
| -rw-r--r-- | pkg/subsystem/linux/parents.go | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/pkg/subsystem/linux/parents.go b/pkg/subsystem/linux/parents.go index fdea4a62f..344bc0db2 100644 --- a/pkg/subsystem/linux/parents.go +++ b/pkg/subsystem/linux/parents.go @@ -3,14 +3,11 @@ package linux -import ( - "github.com/google/syzkaller/pkg/subsystem/entity" - "github.com/google/syzkaller/pkg/subsystem/match" -) +import "github.com/google/syzkaller/pkg/subsystem" // parentTransformations applies all subsystem list transformations that have been implemented. -func parentTransformations(matrix *match.CoincidenceMatrix, - list []*entity.Subsystem) ([]*entity.Subsystem, error) { +func parentTransformations(matrix *CoincidenceMatrix, + list []*subsystem.Subsystem) ([]*subsystem.Subsystem, error) { list = dropSmallSubsystems(matrix, list) list = dropDuplicateSubsystems(matrix, list) err := setParents(matrix, list) @@ -24,13 +21,13 @@ func parentTransformations(matrix *match.CoincidenceMatrix, // We assume A is a child of B if: // 1) B covers more paths than A. // 2) Most of the paths that relate to A also relate to B. -func setParents(matrix *match.CoincidenceMatrix, list []*entity.Subsystem) error { +func setParents(matrix *CoincidenceMatrix, list []*subsystem.Subsystem) error { // Some subsystems might have already been dropeed. - inInput := map[*entity.Subsystem]bool{} + inInput := map[*subsystem.Subsystem]bool{} for _, item := range list { inInput[item] = true } - matrix.NonEmptyPairs(func(a, b *entity.Subsystem, count int) { + matrix.NonEmptyPairs(func(a, b *subsystem.Subsystem, count int) { if !inInput[a] || !inInput[b] { return } @@ -45,10 +42,10 @@ func setParents(matrix *match.CoincidenceMatrix, list []*entity.Subsystem) error } // dropSmallSubsystems removes subsystems for which we have found only a few matches in the filesystem tree. -func dropSmallSubsystems(matrix *match.CoincidenceMatrix, list []*entity.Subsystem) []*entity.Subsystem { +func dropSmallSubsystems(matrix *CoincidenceMatrix, list []*subsystem.Subsystem) []*subsystem.Subsystem { const cutOffCount = 2 - newList := []*entity.Subsystem{} + newList := []*subsystem.Subsystem{} for _, item := range list { if matrix.Count(item) > cutOffCount || len(item.Syscalls) > 0 { newList = append(newList, item) @@ -61,9 +58,9 @@ func dropSmallSubsystems(matrix *match.CoincidenceMatrix, list []*entity.Subsyst // First, if subsystems A and B 100% overlap, we prefer the one that's alphabetically first. // Second, if subsystem A is fully enclosed in subsystem B and constitutes more than 75% of B, // we drop A, since it brings little value. -func dropDuplicateSubsystems(matrix *match.CoincidenceMatrix, list []*entity.Subsystem) []*entity.Subsystem { - drop := map[*entity.Subsystem]struct{}{} - firstIsBetter := func(first, second *entity.Subsystem) bool { +func dropDuplicateSubsystems(matrix *CoincidenceMatrix, list []*subsystem.Subsystem) []*subsystem.Subsystem { + drop := map[*subsystem.Subsystem]struct{}{} + firstIsBetter := func(first, second *subsystem.Subsystem) bool { firstEmail, secondEmail := "", "" if len(first.Lists) > 0 { firstEmail = first.Lists[0] @@ -73,7 +70,7 @@ func dropDuplicateSubsystems(matrix *match.CoincidenceMatrix, list []*entity.Sub } return firstEmail < secondEmail } - matrix.NonEmptyPairs(func(a, b *entity.Subsystem, count int) { + matrix.NonEmptyPairs(func(a, b *subsystem.Subsystem, count int) { // Only consider cases when A is fully enclosed in B, i.e. M[A][B] == M[A][A]. if count != matrix.Count(a) { return @@ -91,7 +88,7 @@ func dropDuplicateSubsystems(matrix *match.CoincidenceMatrix, list []*entity.Sub drop[a] = struct{}{} } }) - newList := []*entity.Subsystem{} + newList := []*subsystem.Subsystem{} for _, item := range list { if _, exists := drop[item]; !exists { newList = append(newList, item) @@ -102,15 +99,15 @@ func dropDuplicateSubsystems(matrix *match.CoincidenceMatrix, list []*entity.Sub // The algorithm runs in O(E * (E + V)). // We expect that E is quite low here, so it should be fine. -func transitiveReduction(list []*entity.Subsystem) { +func transitiveReduction(list []*subsystem.Subsystem) { for _, s := range list { - removeParents := map[*entity.Subsystem]bool{} + removeParents := map[*subsystem.Subsystem]bool{} for _, p := range s.Parents { for otherP := range p.ReachableParents() { removeParents[otherP] = true } } - newParents := []*entity.Subsystem{} + newParents := []*subsystem.Subsystem{} for _, p := range s.Parents { if !removeParents[p] { newParents = append(newParents, p) |
