@@ -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,85 @@ 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+ CandidateSyzlang 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+ ProducedCrashReport string
182+ ReproduceErrors string
183+ }
184+
185+ func reproduceSyzlang (ctx * aflow.Context , args ReproduceSyzlangArgs ) (reproduceSyzlangResult , error ) {
186+ imageData , err := os .ReadFile (args .Image )
187+ if err != nil {
188+ return reproduceSyzlangResult {}, err
189+ }
190+ desc := fmt .Sprintf ("kernel commit %v, kernel config hash %v, image hash %v," +
191+ " vm %v, vm config hash %v, syz repro hash %v, version 4" ,
192+ args .KernelCommit , hash .String (args .KernelConfig ), hash .String (imageData ),
193+ args .Type , hash .String (args .VM ), hash .String (args .CandidateSyzlang ))
194+
195+ type Cached struct {
196+ BugTitle string
197+ Report string
198+ Error string
199+ }
200+
201+ cached , err := aflow .CacheObject (ctx , "repro" , desc , func () (Cached , error ) {
202+ var res Cached
203+ workdir , err := ctx .TempDir ()
204+ if err != nil {
205+ return res , err
206+ }
207+
208+ reproArgs := ReproduceArgs {
209+ Syzkaller : args .Syzkaller ,
210+ Image : args .Image ,
211+ Type : args .Type ,
212+ VM : args .VM ,
213+ ReproOpts : "" ,
214+ ReproSyz : args .CandidateSyzlang ,
215+ ReproC : "" ,
216+ SyzkallerCommit : args .SyzkallerCommit ,
217+ KernelSrc : args .KernelSrc ,
218+ KernelObj : args .KernelObj ,
219+ KernelCommit : args .KernelCommit ,
220+ KernelConfig : args .KernelConfig ,
221+ }
222+
223+ rep , buildError , err := ReproduceCrash (reproArgs , workdir )
224+ if rep != nil {
225+ res .BugTitle = rep .Title
226+ res .Report = string (rep .Report )
227+ }
228+ res .Error = buildError
229+ return res , err
230+ })
231+
232+ if err != nil {
233+ return reproduceSyzlangResult {}, err
234+ }
235+ if cached .Error != "" {
236+ return reproduceSyzlangResult {ReproduceErrors : cached .Error }, nil
237+ } else if cached .Report == "" {
238+ return reproduceSyzlangResult {ReproduceErrors : "reproducer did not crash" }, nil
239+ }
240+ return reproduceSyzlangResult {
241+ ProducedBugTitle : cached .BugTitle ,
242+ ProducedCrashReport : cached .Report ,
243+ }, nil
244+ }
0 commit comments