Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/fuzzer, pkg/corpus: including fault injection into coverage but not corpus #5516

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/corpus/corpus.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ type NewItemEvent struct {
NewCover []uint64
}

func (corpus *Corpus) CovOnlySave(inp NewInput) {
newCover := corpus.cover.MergeDiff(inp.Cover)
if corpus.updates != nil {
select {
case <-corpus.ctx.Done():
case corpus.updates <- NewItemEvent{
Exists: true, // we only saves the coverage
NewCover: newCover,
}:
}
}
}

func (corpus *Corpus) Save(inp NewInput) {
progData := inp.Prog.Serialize()
sig := hash.String(progData)
Expand Down
15 changes: 13 additions & 2 deletions pkg/fuzzer/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,25 +502,36 @@
}

func (job *faultInjectionJob) run(fuzzer *Fuzzer) {
totalCover := cover.FromRaw([]uint64{})
for nth := 1; nth <= 100; nth++ {
fuzzer.Logf(2, "injecting fault into call %v, step %v",
job.call, nth)
newProg := job.p.Clone()
newProg.Calls[job.call].Props.FailNth = nth
result := fuzzer.execute(job.exec, &queue.Request{
Prog: newProg,
Stat: fuzzer.statExecFaultInject,
Prog: newProg,
ExecOpts: setFlags(flatrpc.ExecFlagCollectCover),
Stat: fuzzer.statExecFaultInject,
})
if result.Stop() {
return
}
info := result.Info
if info != nil && info.Extra != nil {
newCover := cover.FromRaw(info.Extra.Cover)
totalCover.Merge(newCover.Serialize())
}
if info != nil && len(info.Calls) > job.call &&
info.Calls[job.call].Flags&flatrpc.CallFlagFaultInjected == 0 {
break
}
}
input := corpus.NewInput{
Cover: totalCover.Serialize(),
}
fuzzer.Config.Corpus.CovOnlySave(input)

}

Check failure on line 534 in pkg/fuzzer/job.go

View workflow job for this annotation

GitHub Actions / build

unnecessary trailing newline (whitespace)

type hintsJob struct {
exec queue.Executor
Expand Down
Loading