aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/subsystem/list.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-01-20 18:00:47 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2023-02-10 14:34:44 +0100
commit5ca014a29eab3dcdecd58d34c0a332fa78958872 (patch)
tree12815af4043ba70470f07aa16ac447b10cc29acd /pkg/subsystem/list.go
parent3a4c5e2da302d43152f2e8b1362d8568c0d57e6e (diff)
pkg/subsystem: add the basic caller-facing interface
Users of the pkg/subsystem are only interested in 1) Fetching the list of subsystems for a given OS. 2) Matching a crash against the extracted set of subsystems.
Diffstat (limited to 'pkg/subsystem/list.go')
-rw-r--r--pkg/subsystem/list.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/subsystem/list.go b/pkg/subsystem/list.go
new file mode 100644
index 000000000..737ab859e
--- /dev/null
+++ b/pkg/subsystem/list.go
@@ -0,0 +1,32 @@
+// Copyright 2023 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+package subsystem
+
+import (
+ "github.com/google/syzkaller/pkg/subsystem/entity"
+)
+
+// In general, it's not correct to assume that subsystems are only determined by target.OS,
+// because subsystems are related not to the user interface of the OS kernel, but rather to
+// the OS kernel implementation.
+//
+// For example, during fuzzing we can treat gVisor in the same way as any other Linux kernel.
+// In reality, however, not a single MAINTAINERS-based rule will work on the gVisor codebase.
+//
+// Therefore, subsystem lists have to be a completely different entity.
+
+var (
+ lists = make(map[string][]*entity.Subsystem)
+)
+
+func RegisterList(name string, list []*entity.Subsystem) {
+ if _, ok := lists[name]; ok {
+ panic(name + " subsystem list already exists!")
+ }
+ lists[name] = list
+}
+
+func GetList(name string) []*entity.Subsystem {
+ return lists[name]
+}