diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2022-12-14 19:23:40 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2022-12-16 10:22:43 +0100 |
| commit | 48ec7344e13eaeee104976fb52d3ed30c1073d5d (patch) | |
| tree | 4610491e2b90c0ec21c61a518673273788f00e27 /pkg/subsystem/extract_test.go | |
| parent | f38211dffe4374a9e09d966b021c00da9d1300c5 (diff) | |
pkg/subsystem: extract subsystems from syz_mount_image$ calls
Dump the mapping between the currently available pseudo syscalls and the
corresponding subsystems.
Diffstat (limited to 'pkg/subsystem/extract_test.go')
| -rw-r--r-- | pkg/subsystem/extract_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/pkg/subsystem/extract_test.go b/pkg/subsystem/extract_test.go index 29512f460..862d1a6e5 100644 --- a/pkg/subsystem/extract_test.go +++ b/pkg/subsystem/extract_test.go @@ -4,6 +4,7 @@ package subsystem import ( + "reflect" "sort" "testing" @@ -67,3 +68,43 @@ io_uring_enter(r0, 0x2ff, 0x0, 0x0, 0x0, 0x0)`, 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/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"}, + }, + } + + for i, test := range tests { + ret := extractor.Extract(&Crash{ + OS: targets.Linux, + GuiltyFiles: []string{test.guilty}, + SyzRepro: test.prog, + }) + sort.Strings(ret) + if !reflect.DeepEqual(ret, test.subsystems) { + t.Fatalf("test #%d: got %+v, wanted %+v", i, ret, test.subsystems) + } + } +} |
