@@ -85,8 +85,18 @@ func ReproduceCrash(args ReproduceArgs, workdir string) (*report.Report, string,
8585 if err != nil {
8686 return nil , "" , err
8787 }
88+ var reproSyz , reproOpts , reproC []byte
89+ if args .ReproSyz != "" {
90+ reproSyz = []byte (args .ReproSyz )
91+ }
92+ if args .ReproOpts != "" {
93+ reproOpts = []byte (args .ReproOpts )
94+ }
95+ if args .ReproC != "" {
96+ reproC = []byte (args .ReproC )
97+ }
8898 // TODO: run multiple instances, handle TestError.Infra, and aggregate results.
89- results , err := env .Test (1 , nil , nil , [] byte ( args . ReproC ) )
99+ results , err := env .Test (1 , reproSyz , reproOpts , reproC )
90100 if err != nil {
91101 return nil , "" , err
92102 }
@@ -160,3 +170,85 @@ func reproduce(ctx *aflow.Context, args ReproduceArgs) (reproduceResult, error)
160170 CrashReport : cached .Report ,
161171 }, nil
162172}
173+
174+ var ReproduceSyzlang = aflow .NewFuncAction ("crash-reproducer" , reproduceSyzlang )
175+
176+ type ReproduceSyzlangArgs struct {
177+ Syzkaller string
178+ Image string
179+ Type string
180+ VM json.RawMessage
181+ CandidateSyzlang string
182+ SyzkallerCommit string
183+ KernelSrc string
184+ KernelObj string
185+ KernelCommit string
186+ KernelConfig string
187+ }
188+
189+ type reproduceSyzlangResult struct {
190+ ProducedBugTitle string
191+ ProducedCrashReport string
192+ ReproduceErrors string
193+ }
194+
195+ func reproduceSyzlang (ctx * aflow.Context , args ReproduceSyzlangArgs ) (reproduceSyzlangResult , error ) {
196+ imageData , err := os .ReadFile (args .Image )
197+ if err != nil {
198+ return reproduceSyzlangResult {}, err
199+ }
200+ desc := fmt .Sprintf ("kernel commit %v, kernel config hash %v, image hash %v," +
201+ " vm %v, vm config hash %v, syz repro hash %v, version 4" ,
202+ args .KernelCommit , hash .String (args .KernelConfig ), hash .String (imageData ),
203+ args .Type , hash .String (args .VM ), hash .String (args .CandidateSyzlang ))
204+
205+ type Cached struct {
206+ BugTitle string
207+ Report string
208+ Error string
209+ }
210+
211+ cached , err := aflow .CacheObject (ctx , "repro" , desc , func () (Cached , error ) {
212+ var res Cached
213+ workdir , err := ctx .TempDir ()
214+ if err != nil {
215+ return res , err
216+ }
217+
218+ reproArgs := ReproduceArgs {
219+ Syzkaller : args .Syzkaller ,
220+ Image : args .Image ,
221+ Type : args .Type ,
222+ VM : args .VM ,
223+ ReproOpts : "" ,
224+ ReproSyz : args .CandidateSyzlang ,
225+ ReproC : "" ,
226+ SyzkallerCommit : args .SyzkallerCommit ,
227+ KernelSrc : args .KernelSrc ,
228+ KernelObj : args .KernelObj ,
229+ KernelCommit : args .KernelCommit ,
230+ KernelConfig : args .KernelConfig ,
231+ }
232+
233+ rep , buildError , err := ReproduceCrash (reproArgs , workdir )
234+ if rep != nil {
235+ res .BugTitle = rep .Title
236+ res .Report = string (rep .Report )
237+ }
238+ res .Error = buildError
239+ return res , err
240+ })
241+
242+ if err != nil {
243+ return reproduceSyzlangResult {}, err
244+ }
245+ if cached .Error != "" {
246+ return reproduceSyzlangResult {ReproduceErrors : cached .Error }, nil
247+ } else if cached .Report == "" {
248+ return reproduceSyzlangResult {ReproduceErrors : "reproducer did not crash" }, nil
249+ }
250+ return reproduceSyzlangResult {
251+ ProducedBugTitle : cached .BugTitle ,
252+ ProducedCrashReport : cached .Report ,
253+ }, nil
254+ }
0 commit comments