From fcac021fe5ed726e926d2e585e7a2f59d8827f21 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 16 Dec 2022 00:01:51 +0100 Subject: pkg/subsystem: extract filesystems from guilty path As we can easily do the subsystem <-> path mapping, let's also use it for determining the actual involved filesystem. --- pkg/subsystem/extract.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pkg/subsystem/extract.go') diff --git a/pkg/subsystem/extract.go b/pkg/subsystem/extract.go index 4d952011f..1908f5e54 100644 --- a/pkg/subsystem/extract.go +++ b/pkg/subsystem/extract.go @@ -5,6 +5,7 @@ package subsystem import ( "regexp" + "sync" "github.com/google/syzkaller/prog" ) @@ -58,9 +59,24 @@ func linuxPathToSubsystems(path string) []string { if vfsPathRegexp.MatchString(path) { ret = append(ret, "vfs") } + linuxSubsystemsOnce.Do(func() { + for name, info := range linuxSubsystems { + linuxSubsystemRegexps[name] = regexp.MustCompile("^/?" + info.path + ".*") + } + }) + for name, pattern := range linuxSubsystemRegexps { + if pattern.MatchString(path) { + ret = append(ret, name) + } + } return ret } +var ( + linuxSubsystemsOnce sync.Once + linuxSubsystemRegexps = map[string]*regexp.Regexp{} +) + func linuxCallToSubsystems(call string) []string { name := linuxCallToSubsystemsMap[call] if name != "" { -- cgit mrf-deployment