github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/dashboard/app/linux_reporting_test.go (about) 1 // Copyright 2022 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package main 5 6 import ( 7 "testing" 8 9 "github.com/google/syzkaller/dashboard/dashapi" 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestFsSubsystemFlow(t *testing.T) { 14 // Test that we can do the following: 15 // 1. Delay the reporting of possible vfs bugs until we have found a reproducer. 16 // 2. Once the reproducer comes, extract the extra subsystems and report it. 17 18 c := NewCtx(t) 19 defer c.Close() 20 21 client := c.makeClient(clientPublicFs, keyPublicFs, true) 22 build := testBuild(1) 23 client.UploadBuild(build) 24 25 // A. Make sure non-fs bugs are not affected. 26 // ----------------------------------------- 27 28 crash := testCrash(build, 1) 29 crash.Title = "WARNING: abcd" 30 crash.Log = []byte("log log log") 31 crash.GuiltyFiles = []string{"kernel/kernel.c"} 32 crash.Maintainers = []string{"maintainer@kernel.org"} 33 client.ReportCrash(crash) 34 35 // We skip the first stage and report the bug right away. 36 reply := c.pollEmailBug() 37 c.expectEQ(reply.Subject, "[syzbot] [kernel?] WARNING: abcd") 38 39 // B. Send a non-vfs bug without a reproducer. 40 // ----------------------------------------- 41 42 crash = testCrash(build, 2) 43 crash.Title = "WARNING in nilfs_dat_commit_end" 44 crash.GuiltyFiles = []string{"fs/nilfs2/dat.c"} 45 crash.Log = []byte("log log log") 46 crash.Maintainers = []string{"maintainer@kernel.org"} 47 client.ReportCrash(crash) 48 49 reply = c.pollEmailBug() 50 // The subsystem should have been taken from the guilty path. 51 c.expectEQ(reply.Subject, "[syzbot] [nilfs?] WARNING in nilfs_dat_commit_end") 52 assert.ElementsMatch(t, reply.To, []string{ 53 "konishi.ryusuke@gmail.com", 54 "linux-kernel@vger.kernel.org", 55 "linux-nilfs@vger.kernel.org", 56 "maintainer@kernel.org", 57 "test@syzkaller.com", 58 }) 59 60 // C. Send a possibly vfs bug without a reproducer. 61 // ----------------------------------------- 62 63 crash = testCrash(build, 3) 64 crash.Title = "WARNING in do_mkdirat" 65 crash.GuiltyFiles = []string{"fs/namei.c"} 66 crash.Log = []byte("log log log") 67 crash.Maintainers = []string{"maintainer@kernel.org"} 68 client.ReportCrash(crash) 69 70 // As there's no other information, the bug is left at the first reporting. 71 c.client.pollNotifs(0) 72 vfsBug := client.pollBug() 73 74 // D. Now report a reproducer for the (C) bug that does image mounting. 75 // ----------------------------------------- 76 77 crash = testCrash(build, 4) 78 crash.Title = "WARNING in do_mkdirat" 79 crash.GuiltyFiles = []string{"fs/namei.c"} 80 crash.Log = []byte("log log log") 81 // nolint: lll 82 crash.ReproSyz = []byte(`syz_mount_image$ntfs3(&(0x7f0000000240), &(0x7f000001f3c0)='./file0\x00', 0xc40, &(0x7f00000005c0)=ANY=[@ANYBLOB="0032"], 0x3, 0x1f398, &(0x7f000003e7c0)="111") 83 r0 = openat(0xffffffffffffff9c, &(0x7f0000000040)='.\x00', 0x0, 0x0) 84 mkdirat(r0, &(0x7f0000000180)='./bus\x00', 0x0) 85 mkdirat(r0, &(0x7f0000000280)='./bus/file0\x00', 0x0) 86 renameat2(r0, &(0x7f00000004c0)='./file0\x00', r0, &(0x7f0000000500)='./bus/file0/file0\x00', 0x0)`) 87 crash.Maintainers = []string{"maintainer@kernel.org"} 88 client.ReportCrash(crash) 89 90 // Check that we're ready for upstreaming. 91 c.client.pollNotifs(1) 92 client.updateBug(vfsBug.ID, dashapi.BugStatusUpstream, "") 93 // .. and poll the email. 94 reply = c.pollEmailBug() 95 c.expectEQ(reply.Subject, "[syzbot] [ntfs3?] WARNING in do_mkdirat") 96 // Make sure ntfs3 maintainers are in the recipients. 97 assert.ElementsMatch(t, reply.To, []string{ 98 "almaz.alexandrovich@paragon-software.com", 99 "linux-kernel@vger.kernel.org", 100 "maintainer@kernel.org", 101 "ntfs3@lists.linux.dev", 102 "test@syzkaller.com", 103 }) 104 } 105 106 func TestVfsSubsystemFlow(t *testing.T) { 107 // Test that we can do the following: 108 // 1. Delay the reporting of possible vfs bugs until we have found a reproducer. 109 // 2. Once the reproducer comes, extract the extra subsystems and report it. 110 111 c := NewCtx(t) 112 defer c.Close() 113 114 client := c.makeClient(clientPublicFs, keyPublicFs, true) 115 build := testBuild(1) 116 client.UploadBuild(build) 117 118 // A. Send a possibly vfs bug without a reproducer. 119 // ----------------------------------------- 120 121 crash := testCrash(build, 1) 122 crash.Title = "WARNING in do_mkdirat2" 123 crash.GuiltyFiles = []string{"fs/namei.c"} 124 crash.Log = []byte("log log log") 125 crash.Maintainers = []string{"maintainer@kernel.org"} 126 client.ReportCrash(crash) 127 128 // As there's no other information, the bug is left at the first reporting. 129 c.client.pollNotifs(0) 130 vfsBug := client.pollBug() 131 132 // B. Now report a reproducer for the (C) bug that does NO image mounting. 133 // ----------------------------------------- 134 135 crash = testCrash(build, 2) 136 crash.Title = "WARNING in do_mkdirat2" 137 crash.GuiltyFiles = []string{"fs/namei.c"} 138 crash.Log = []byte("log log log") 139 crash.ReproSyz = []byte(`r0 = openat(0xffffffffffffff9c, &(0x7f0000000040)='.\x00', 0x0, 0x0) 140 mkdirat(r0, &(0x7f0000000180)='./bus\x00', 0x0) 141 mkdirat(r0, &(0x7f0000000280)='./bus/file0\x00', 0x0) 142 renameat2(r0, &(0x7f00000004c0)='./file0\x00', r0, &(0x7f0000000500)='./bus/file0/file0\x00', 0x0)`) 143 crash.Maintainers = []string{"maintainer@kernel.org"} 144 client.ReportCrash(crash) 145 146 // Check that we're ready for upstreaming. 147 c.client.pollNotifs(1) 148 client.updateBug(vfsBug.ID, dashapi.BugStatusUpstream, "") 149 // .. and poll the email. 150 reply := c.pollEmailBug() 151 c.expectEQ(reply.Subject, "[syzbot] [fs?] WARNING in do_mkdirat2") 152 }