From 18f846ca807cfc6df9c3da3c0ab08251277dfefb Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 1 Dec 2021 17:25:40 +0000 Subject: all: add the `rerun` call property To be able to collide specific syscalls more precisely, we need to repeat the process many times. Introduce the `rerun` call property, which instructs `syz-executor` to repeat the call the specified number of times. The intended use is: call1() (rerun: 100, async) call2() (rerun: 100) For now, assign rerun values randomly to consecutive pairs of calls, where the first one is async. --- pkg/csource/csource.go | 8 ++++++++ pkg/csource/csource_test.go | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'pkg/csource') diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index 32e01ff1e..6dd8bdcd6 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -253,6 +253,14 @@ func (ctx *context) generateCalls(p prog.ExecProg, trace bool) ([]string, []uint ctx.emitCall(w, call, ci, resCopyout || argCopyout, trace) + if call.Props.Rerun > 0 { + // TODO: remove this legacy C89-style definition once we figure out what to do with Akaros. + fmt.Fprintf(w, "\t{\n\tint i;\n") + fmt.Fprintf(w, "\tfor(i = 0; i < %v; i++) {\n", call.Props.Rerun) + // Rerun invocations should not affect the result value. + ctx.emitCall(w, call, ci, false, false) + fmt.Fprintf(w, "\t\t}\n\t}\n") + } // Copyout. if resCopyout || argCopyout { ctx.copyout(w, call, resCopyout) diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index 885d75f67..fc3b21573 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -70,13 +70,16 @@ func testTarget(t *testing.T, target *prog.Target, full bool) { p.Calls = append(p.Calls, minimized.Calls...) opts = allOptionsPermutations(target.OS) } - // Test fault injection and async call generation as well. + // Test various call properties. if len(p.Calls) > 0 { p.Calls[0].Props.FailNth = 1 } if len(p.Calls) > 1 { p.Calls[1].Props.Async = true } + if len(p.Calls) > 2 { + p.Calls[2].Props.Rerun = 4 + } for opti, opts := range opts { if testing.Short() && opts.HandleSegv { // HandleSegv can radically increase compilation time/memory consumption on large programs. -- cgit mrf-deployment