@@ -86,7 +86,7 @@ func ReproduceCrash(args ReproduceArgs, workdir string) (*report.Report, string,
8686 return nil , "" , err
8787 }
8888 // TODO: run multiple instances, handle TestError.Infra, and aggregate results.
89- results , err := env .Test (1 , nil , nil , []byte (args .ReproC ))
89+ results , err := env .Test (1 , [] byte ( args . ReproSyz ), [] byte ( args . ReproOpts ) , []byte (args .ReproC ))
9090 if err != nil {
9191 return nil , "" , err
9292 }
@@ -160,3 +160,83 @@ func reproduce(ctx *aflow.Context, args ReproduceArgs) (reproduceResult, error)
160160 CrashReport : cached .Report ,
161161 }, nil
162162}
163+
164+ var ReproduceSyzlang = aflow .NewFuncAction ("crash-reproducer" , reproduceSyzlang )
165+
166+ type ReproduceSyzlangArgs struct {
167+ Syzkaller string
168+ Image string
169+ Type string
170+ VM json.RawMessage
171+ Syzlang string
172+ SyzkallerCommit string
173+ KernelSrc string
174+ KernelObj string
175+ KernelCommit string
176+ KernelConfig string
177+ }
178+
179+ type reproduceSyzlangResult struct {
180+ ProducedBugTitle string
181+ ReproduceErrors string
182+ }
183+
184+ func reproduceSyzlang (ctx * aflow.Context , args ReproduceSyzlangArgs ) (reproduceSyzlangResult , error ) {
185+ imageData , err := os .ReadFile (args .Image )
186+ if err != nil {
187+ return reproduceSyzlangResult {}, err
188+ }
189+ desc := fmt .Sprintf ("kernel commit %v, kernel config hash %v, image hash %v," +
190+ " vm %v, vm config hash %v, syz repro hash %v, version 4" ,
191+ args .KernelCommit , hash .String (args .KernelConfig ), hash .String (imageData ),
192+ args .Type , hash .String (args .VM ), hash .String (args .Syzlang ))
193+
194+ type Cached struct {
195+ BugTitle string
196+ Report string
197+ Error string
198+ }
199+
200+ cached , err := aflow .CacheObject (ctx , "repro" , desc , func () (Cached , error ) {
201+ var res Cached
202+ workdir , err := ctx .TempDir ()
203+ if err != nil {
204+ return res , err
205+ }
206+
207+ reproArgs := ReproduceArgs {
208+ Syzkaller : args .Syzkaller ,
209+ Image : args .Image ,
210+ Type : args .Type ,
211+ VM : args .VM ,
212+ ReproOpts : "" ,
213+ ReproSyz : args .Syzlang ,
214+ ReproC : "" ,
215+ SyzkallerCommit : args .SyzkallerCommit ,
216+ KernelSrc : args .KernelSrc ,
217+ KernelObj : args .KernelObj ,
218+ KernelCommit : args .KernelCommit ,
219+ KernelConfig : args .KernelConfig ,
220+ }
221+
222+ rep , buildError , err := ReproduceCrash (reproArgs , workdir )
223+ if rep != nil {
224+ res .BugTitle = rep .Title
225+ res .Report = string (rep .Report )
226+ }
227+ res .Error = buildError
228+ return res , err
229+ })
230+
231+ if err != nil {
232+ return reproduceSyzlangResult {}, err
233+ }
234+ if cached .Error != "" {
235+ return reproduceSyzlangResult {ReproduceErrors : cached .Error }, nil
236+ } else if cached .Report == "" {
237+ return reproduceSyzlangResult {ReproduceErrors : "reproducer did not crash" }, nil
238+ }
239+ return reproduceSyzlangResult {
240+ ProducedBugTitle : cached .BugTitle ,
241+ }, nil
242+ }
0 commit comments