aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/subsystem
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-12-14 19:09:08 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2022-12-16 10:22:43 +0100
commitf38211dffe4374a9e09d966b021c00da9d1300c5 (patch)
treefb058a6f584d397296db3848df79e8974c08b7f0 /pkg/subsystem
parent2083933ab27c27d8d184d31cc8957851a4ec658f (diff)
dashboard: extract subsystems for saved crashes
Invoke the extractor code at pkg/subsystem and store the result into the Bug entity. Augment the Maintainers content by per-subsystem emails.
Diffstat (limited to 'pkg/subsystem')
-rw-r--r--pkg/subsystem/extract.go31
-rw-r--r--pkg/subsystem/extract_test.go5
2 files changed, 25 insertions, 11 deletions
diff --git a/pkg/subsystem/extract.go b/pkg/subsystem/extract.go
index caf80636e..181c15835 100644
--- a/pkg/subsystem/extract.go
+++ b/pkg/subsystem/extract.go
@@ -7,11 +7,11 @@ import (
"regexp"
"github.com/google/syzkaller/prog"
- "github.com/google/syzkaller/sys/targets"
)
type SubsystemExtractor struct {
- CallToSubsystems func(call string) []string
+ pathToSubsystems func(path string) []string
+ callToSubsystems func(call string) []string
}
// Crash contains the subset of Crash fields relevant for subsystem extraction.
@@ -21,21 +21,26 @@ type Crash struct {
SyzRepro string
}
+func MakeLinuxSubsystemExtractor() *SubsystemExtractor {
+ return &SubsystemExtractor{
+ pathToSubsystems: linuxPathToSubsystems,
+ }
+}
+
func (se *SubsystemExtractor) Extract(crash *Crash) []string {
retMap := map[string]bool{}
// Currently we only have the dumbest possible implementation of subsystem detection.
- if crash.OS == targets.Linux {
- for _, guiltyPath := range crash.GuiltyFiles {
- if vfsPathRegexp.MatchString(guiltyPath) {
- retMap["vfs"] = true
- break
+ if se.pathToSubsystems != nil {
+ for _, path := range crash.GuiltyFiles {
+ for _, value := range se.pathToSubsystems(path) {
+ retMap[value] = true
}
}
}
- if se.CallToSubsystems != nil {
+ if se.callToSubsystems != nil {
callSet, _, _ := prog.CallSet([]byte(crash.SyzRepro))
for call := range callSet {
- for _, subsystem := range se.CallToSubsystems(call) {
+ for _, subsystem := range se.callToSubsystems(call) {
retMap[subsystem] = true
}
}
@@ -47,6 +52,14 @@ func (se *SubsystemExtractor) Extract(crash *Crash) []string {
return retSlice
}
+func linuxPathToSubsystems(path string) []string {
+ ret := []string{}
+ if vfsPathRegexp.MatchString(path) {
+ ret = append(ret, "vfs")
+ }
+ return ret
+}
+
var (
vfsPathRegexp = regexp.MustCompile(`^fs/[^/]+\.c`)
)
diff --git a/pkg/subsystem/extract_test.go b/pkg/subsystem/extract_test.go
index 936f4fa8e..29512f460 100644
--- a/pkg/subsystem/extract_test.go
+++ b/pkg/subsystem/extract_test.go
@@ -12,7 +12,7 @@ import (
)
func TestSimpleLinuxExtract(t *testing.T) {
- se := &SubsystemExtractor{}
+ se := MakeLinuxSubsystemExtractor()
ret := se.Extract(&Crash{
OS: targets.Linux,
@@ -34,7 +34,8 @@ func TestSimpleLinuxExtract(t *testing.T) {
func TestProgCallRules(t *testing.T) {
se := &SubsystemExtractor{
- CallToSubsystems: func(call string) []string {
+ pathToSubsystems: linuxPathToSubsystems,
+ callToSubsystems: func(call string) []string {
ret := map[string][]string{
// Intentionally add some that are not present in the test below.
"test": {"test"},