aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/subsystem
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-02-07 16:22:52 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2023-02-16 11:29:36 +0100
commit3256fb23a09736243944db98d8608b490afb9d60 (patch)
tree4610beab0765c2edc337391f4e84422edd34d599 /pkg/subsystem
parent2f0f5f6d638c8a24c1b8b04ebc9e303d330644cc (diff)
pkg/subsystem: remove the legacy code
Now it's no longer needed.
Diffstat (limited to 'pkg/subsystem')
-rw-r--r--pkg/subsystem/legacy/extract.go134
-rw-r--r--pkg/subsystem/legacy/extract_test.go109
-rw-r--r--pkg/subsystem/legacy/maintainers.go57
3 files changed, 0 insertions, 300 deletions
diff --git a/pkg/subsystem/legacy/extract.go b/pkg/subsystem/legacy/extract.go
deleted file mode 100644
index 5c321dc97..000000000
--- a/pkg/subsystem/legacy/extract.go
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2022 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 legacy
-
-import (
- "regexp"
- "sync"
-
- "github.com/google/syzkaller/prog"
-)
-
-type SubsystemExtractor struct {
- pathToSubsystems func(path string) []string
- callToSubsystems func(call string) []string
-}
-
-// Crash contains the subset of Crash fields relevant for subsystem extraction.
-type Crash struct {
- OS string
- GuiltyFiles []string
- SyzRepro string
-}
-
-func MakeLinuxSubsystemExtractor() *SubsystemExtractor {
- return &SubsystemExtractor{
- pathToSubsystems: linuxPathToSubsystems,
- callToSubsystems: linuxCallToSubsystems,
- }
-}
-
-func (se *SubsystemExtractor) Extract(crash *Crash) []string {
- retMap := map[string]bool{}
- // Currently we only have the dumbest possible implementation of subsystem detection.
- if se.pathToSubsystems != nil {
- for _, path := range crash.GuiltyFiles {
- for _, value := range se.pathToSubsystems(path) {
- retMap[value] = true
- }
- }
- }
- if se.callToSubsystems != nil {
- callSet, _, _ := prog.CallSet([]byte(crash.SyzRepro))
- for call := range callSet {
- for _, subsystem := range se.callToSubsystems(call) {
- retMap[subsystem] = true
- }
- }
- }
- retSlice := []string{}
- for name := range retMap {
- retSlice = append(retSlice, name)
- }
- return retSlice
-}
-
-func linuxPathToSubsystems(path string) []string {
- ret := []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 != "" {
- return []string{name}
- }
- return nil
-}
-
-var linuxCallToSubsystemsMap = map[string]string{
- "syz_mount_image$adfs": "adfs",
- "syz_mount_image$affs": "affs",
- "syz_mount_image$befs": "befs",
- "syz_mount_image$bfs": "bfs",
- "syz_mount_image$btrfs": "btrfs",
- "syz_mount_image$cramfs": "cramfs",
- "syz_mount_image$efs": "efs",
- "syz_mount_image$erofs": "erofs",
- "syz_mount_image$exfat": "exfat",
- "syz_mount_image$ext4": "ext4",
- "syz_mount_image$f2fs": "f2fs",
- "syz_mount_image$gfs2": "gfs2",
- "syz_mount_image$gfs2meta": "gfs2",
- "syz_mount_image$hfs": "hfs",
- "syz_mount_image$hfsplus": "hfsplus",
- "syz_mount_image$hpfs": "hpfs",
- "syz_mount_image$iso9660": "iso9660",
- "syz_mount_image$jffs2": "jffs2",
- "syz_mount_image$jfs": "jfs",
- "syz_mount_image$minix": "minix",
- "syz_mount_image$msdos": "fat",
- "syz_mount_image$nilfs2": "nilfs2",
- "syz_mount_image$ntfs": "ntfs",
- "syz_mount_image$ntfs3": "ntfs3",
- "syz_mount_image$ocfs2": "ocfs2",
- "syz_mount_image$omfs": "omfs",
- "syz_mount_image$qnx4": "qnx4",
- "syz_mount_image$qnx6": "qnx6",
- "syz_mount_image$reiserfs": "reiserfs",
- "syz_mount_image$romfs": "romfs",
- "syz_mount_image$squashfs": "squashfs",
- "syz_mount_image$sysv": "sysv",
- "syz_mount_image$tmpfs": "tmpfs",
- "syz_mount_image$ubifs": "ubifs",
- "syz_mount_image$udf": "udf",
- "syz_mount_image$ufs": "ufs",
- "syz_mount_image$v7": "v7",
- "syz_mount_image$vfat": "fat",
- "syz_mount_image$vxfs": "vxfs",
- "syz_mount_image$xfs": "xfs",
- "syz_mount_image$zonefs": "zonefs",
-}
-
-var (
- vfsPathRegexp = regexp.MustCompile(`^fs/[^/]+\.c`)
-)
diff --git a/pkg/subsystem/legacy/extract_test.go b/pkg/subsystem/legacy/extract_test.go
deleted file mode 100644
index d23ec11e2..000000000
--- a/pkg/subsystem/legacy/extract_test.go
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2022 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 legacy
-
-import (
- "sort"
- "testing"
-
- "github.com/google/syzkaller/sys/targets"
- "github.com/stretchr/testify/assert"
-)
-
-func TestProgCallRules(t *testing.T) {
- se := &SubsystemExtractor{
- pathToSubsystems: linuxPathToSubsystems,
- callToSubsystems: func(call string) []string {
- ret := map[string][]string{
- // Intentionally add some that are not present in the test below.
- "test": {"test"},
- "syz_io_uring_setup": {"io_uring"},
- "ioctl$TIOCSETD": {"tty_ioctls", "tty"},
- // Some calls are also omitted to verify that the code works fine this way.
- }
- return ret[call]
- },
- }
-
- ret := se.Extract(&Crash{
- OS: targets.Linux,
- GuiltyFiles: []string{
- "mm/page-writeback.c",
- },
- // nolint: lll
- SyzRepro: `# https://syzkaller.appspot.com/bug?id=708185e841adf6ca28fc50b126fdf9825fd8ae43
-# See https://goo.gl/kgGztJ for information about syzkaller reproducers.
-#{"repeat":true,"procs":1,"slowdown":1,"sandbox":"","close_fds":false}
-r0 = syz_io_uring_setup(0x3ee4, &(0x7f0000000240), &(0x7f0000002000/0x2000)=nil, &(0x7f0000ffd000/0x3000)=nil, &(0x7f0000000100)=<r1=>0x0, &(0x7f0000000140)=<r2=>0x0)
-socket$inet_udplite(0x2, 0x2, 0x88)
-r3 = openat$ptmx(0xffffffffffffff9c, &(0x7f0000000040), 0x8a04, 0x0)
-syz_io_uring_submit(r1, r2, &(0x7f0000000000)=@IORING_OP_READ=@pass_buffer={0x16, 0x0, 0x0, @fd_index=0x5, 0x0, 0x0}, 0x0)
-ioctl$TIOCSETD(r3, 0x5423, &(0x7f0000000580)=0x3)
-io_uring_enter(r0, 0x2ff, 0x0, 0x0, 0x0, 0x0)`,
- })
- sort.Strings(ret)
- assert.Exactlyf(t, ret, []string{"io_uring", "tty", "tty_ioctls"},
- "invalid resulting subsystems: %s", ret)
-}
-
-func TestFsSubsystemExtraction(t *testing.T) {
- extractor := MakeLinuxSubsystemExtractor()
-
- tests := []struct {
- guilty string
- prog string
- subsystems []string
- }{
- {
- guilty: "fs/abc.c",
- subsystems: []string{"vfs"},
- },
- {
- guilty: "fs/nilfs2/dat.c",
- // nolint: lll
- prog: `syz_mount_image$nilfs2(&(0x7f0000000000), &(0x7f0000000100)='./file0\x00', 0x100000, 0x3b, &(0x7f0000000200)=[{&(0x7f0000011240)="02", 0x1}, {&(0x7f0000012a40)="03000000", 0x4, 0x1}], 0x0, &(0x7f00000131c0), 0x1)
-openat$incfs(0xffffffffffffff9c, &(0x7f0000000000)='.pending_reads\x00', 0x4040, 0x0)`,
- subsystems: []string{"nilfs2"},
- },
- {
- guilty: "fs/namei.c",
- // nolint: lll
- prog: `syz_mount_image$ntfs3(&(0x7f0000000240), &(0x7f000001f3c0)='./file0\x00', 0xc40, &(0x7f00000005c0)=ANY=[@ANYBLOB="0032"], 0x3, 0x1f398, &(0x7f000003e7c0)="111")
-r0 = openat(0xffffffffffffff9c, &(0x7f0000000040)='.\x00', 0x0, 0x0)
-mkdirat(r0, &(0x7f0000000180)='./bus\x00', 0x0)
-mkdirat(r0, &(0x7f0000000280)='./bus/file0\x00', 0x0)
-renameat2(r0, &(0x7f00000004c0)='./file0\x00', r0, &(0x7f0000000500)='./bus/file0/file0\x00', 0x0)`,
- subsystems: []string{"ntfs3", "vfs"},
- },
- {
- guilty: "fs/ext4/file.c",
- // nolint: lll
- prog: `syz_mount_image$ntfs3(&(0x7f0000000240), &(0x7f000001f3c0)='./file0\x00', 0xc40, &(0x7f00000005c0)=ANY=[@ANYBLOB="0032"], 0x3, 0x1f398, &(0x7f000003e7c0)="111")
-r0 = openat(0xffffffffffffff9c, &(0x7f0000000040)='.\x00', 0x0, 0x0)
-mkdirat(r0, &(0x7f0000000180)='./bus\x00', 0x0)
-mkdirat(r0, &(0x7f0000000280)='./bus/file0\x00', 0x0)
-renameat2(r0, &(0x7f00000004c0)='./file0\x00', r0, &(0x7f0000000500)='./bus/file0/file0\x00', 0x0)`,
- subsystems: []string{"ntfs3", "ext4"},
- },
- {
- guilty: "fs/gfs2/ops_fstype.c",
- subsystems: []string{"gfs2"},
- },
- {
- guilty: "net/mac80211/main.c",
- subsystems: []string{},
- },
- }
-
- for i, test := range tests {
- ret := extractor.Extract(&Crash{
- OS: targets.Linux,
- GuiltyFiles: []string{test.guilty},
- SyzRepro: test.prog,
- })
- sort.Strings(ret)
- sort.Strings(test.subsystems)
- assert.Exactlyf(t, ret, test.subsystems, "#%d: invalid resulting subsystems", i)
- }
-}
diff --git a/pkg/subsystem/legacy/maintainers.go b/pkg/subsystem/legacy/maintainers.go
deleted file mode 100644
index 948c2d851..000000000
--- a/pkg/subsystem/legacy/maintainers.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2022 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 legacy
-
-func LinuxGetMaintainers(subsystemName string) []string {
- return linuxSubsystems[subsystemName].cc
-}
-
-type linuxSubsystemInfo struct {
- path string
- cc []string
-}
-
-// These are taken from Linux v6.1. There will be no need to store them here once we
-// begin to automatically parse the MAINTAINERS file.
-
-// nolint:lll
-var linuxSubsystems = map[string]linuxSubsystemInfo{
- "adfs": {path: "fs/adfs/", cc: []string{}},
- "affs": {path: "fs/affs/", cc: []string{"linux-fsdevel@vger.kernel.org", "dsterba@suse.com"}},
- "befs": {path: "fs/befs/", cc: []string{"luisbg@kernel.org", "salah.triki@gmail.com"}},
- "bfs": {path: "fs/bfs/", cc: []string{"aivazian.tigran@gmail.com"}},
- "btrfs": {path: "fs/btrfs/", cc: []string{"josef@toxicpanda.com", "dsterba@suse.com", "linux-btrfs@vger.kernel.org", "clm@fb.com"}},
- "cramfs": {path: "fs/cramfs/", cc: []string{"nico@fluxnic.net"}},
- "efs": {path: "fs/efs/", cc: []string{}},
- "erofs": {path: "fs/erofs/", cc: []string{"xiang@kernel.org", "chao@kernel.org", "linux-erofs@lists.ozlabs.org"}},
- "exfat": {path: "fs/exfat/", cc: []string{"linkinjeon@kernel.org", "sj1557.seo@samsung.com", "linux-fsdevel@vger.kernel.org"}},
- "fat": {path: "fs/fat/", cc: []string{"hirofumi@mail.parknet.co.jp"}},
- "ext4": {path: "fs/ext4/", cc: []string{"linux-ext4@vger.kernel.org", "tytso@mit.edu", "adilger.kernel@dilger.ca"}},
- "f2fs": {path: "fs/f2fs/", cc: []string{"linux-f2fs-devel@lists.sourceforge.net", "jaegeuk@kernel.org", "chao@kernel.org"}},
- "gfs2": {path: "fs/gfs2/", cc: []string{"cluster-devel@redhat.com", "rpeterso@redhat.com", "agruenba@redhat.com"}},
- "hfs": {path: "fs/hfs/", cc: []string{"linux-fsdevel@vger.kernel.org"}},
- "hfsplus": {path: "fs/hfsplus/", cc: []string{"linux-fsdevel@vger.kernel.org"}},
- "hpfs": {path: "fs/hpfs/", cc: []string{"mikulas@artax.karlin.mff.cuni.cz"}},
- "iso9660": {path: "fs/isofs/", cc: []string{}},
- "jffs2": {path: "fs/jffs2/", cc: []string{"linux-mtd@lists.infradead.org", "dwmw2@infradead.org", "richard@nod.at"}},
- "jfs": {path: "fs/jfs/", cc: []string{"jfs-discussion@lists.sourceforge.net", "shaggy@kernel.org"}},
- "minix": {path: "fs/minix/", cc: []string{}},
- "nilfs2": {path: "fs/nilfs2/", cc: []string{"linux-nilfs@vger.kernel.org", "konishi.ryusuke@gmail.com"}},
- "ntfs": {path: "fs/ntfs/", cc: []string{"linux-ntfs-dev@lists.sourceforge.net", "anton@tuxera.com"}},
- "ntfs3": {path: "fs/ntfs3/", cc: []string{"ntfs3@lists.linux.dev", "almaz.alexandrovich@paragon-software.com"}},
- "ocfs2": {path: "fs/ocfs2/", cc: []string{"ocfs2-devel@oss.oracle.com", "mark@fasheh.com", "jlbec@evilplan.org", "joseph.qi@linux.alibaba.com"}},
- "omfs": {path: "fs/omfs/", cc: []string{"linux-karma-devel@lists.sourceforge.net", "me@bobcopeland.com"}},
- "qnx4": {path: "fs/qnx4/", cc: []string{"al@alarsen.net"}},
- "qnx6": {path: "fs/qnx6/", cc: []string{}},
- "reiserfs": {path: "fs/reiserfs/", cc: []string{"reiserfs-devel@vger.kernel.org"}},
- "romfs": {path: "fs/romfs/", cc: []string{}},
- "squashfs": {path: "fs/squashfs/", cc: []string{"phillip@squashfs.org.uk", "squashfs-devel@lists.sourceforge.net"}},
- "sysv": {path: "fs/sysv/", cc: []string{"hch@infradead.org"}},
- "tmpfs": {path: "mm/shmem.c", cc: []string{"linux-mm@kvack.org", "akpm@linux-foundation.org", "hughd@google.com"}},
- "ubifs": {path: "fs/ubifs/", cc: []string{"linux-mtd@lists.infradead.org", "richard@nod.at"}},
- "udf": {path: "fs/udf/", cc: []string{"jack@suse.com"}},
- "ufs": {path: "fs/ufs/", cc: []string{"dushistov@mail.ru"}},
- "vxfs": {path: "fs/freevxfs/", cc: []string{"hch@infradead.org"}},
- "xfs": {path: "fs/xfs/", cc: []string{"linux-xfs@vger.kernel.org", "djwong@kernel.org"}},
- "zonefs": {path: "fs/zonefs/", cc: []string{"linux-fsdevel@vger.kernel.org", "damien.lemoal@opensource.wdc.com", "naohiro.aota@wdc.com"}}}