diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-04-18 11:19:17 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-30 09:36:03 +0000 |
| commit | 67a25df5ff7f0d2a8b09049c3b30ecc79afa3f1e (patch) | |
| tree | d56b73658b823fef52b72036c0b36fcdd3bb6b79 /pkg/fuzzer | |
| parent | ff1693fc52bf20fb123b27fe87212ce216b0ef58 (diff) | |
pkg/fuzzer: move Signal type from rpctype
Now that manager sends ipc.ExecOpts to the fuzzer,
there is no point in having Signal type in rpctype.
It belongs to pkg/fuzzer.
Diffstat (limited to 'pkg/fuzzer')
| -rw-r--r-- | pkg/fuzzer/fuzzer.go | 17 | ||||
| -rw-r--r-- | pkg/fuzzer/fuzzer_test.go | 5 | ||||
| -rw-r--r-- | pkg/fuzzer/job.go | 15 |
3 files changed, 21 insertions, 16 deletions
diff --git a/pkg/fuzzer/fuzzer.go b/pkg/fuzzer/fuzzer.go index a5b338b13..42fc62ea5 100644 --- a/pkg/fuzzer/fuzzer.go +++ b/pkg/fuzzer/fuzzer.go @@ -14,7 +14,6 @@ import ( "github.com/google/syzkaller/pkg/corpus" "github.com/google/syzkaller/pkg/ipc" - "github.com/google/syzkaller/pkg/rpctype" "github.com/google/syzkaller/pkg/signal" "github.com/google/syzkaller/pkg/stats" "github.com/google/syzkaller/prog" @@ -87,7 +86,7 @@ type Request struct { Prog *prog.Prog NeedCover bool NeedRawCover bool - NeedSignal rpctype.SignalType + NeedSignal SignalType NeedHints bool // If specified, the resulting signal for call SignalFilterCall // will include subset of it even if it's not new. @@ -99,6 +98,14 @@ type Request struct { resultC chan *Result } +type SignalType int + +const ( + NoSignal SignalType = 0 // we don't need any signal + NewSignal SignalType = 1 // we need the newly seen signal + AllSignal SignalType = 2 // we need all signal +) + type Result struct { Info *ipc.ProgInfo Stop bool @@ -108,7 +115,7 @@ func (fuzzer *Fuzzer) Done(req *Request, res *Result) { // Triage individual calls. // We do it before unblocking the waiting threads because // it may result it concurrent modification of req.Prog. - if req.NeedSignal != rpctype.NoSignal && res.Info != nil { + if req.NeedSignal != NoSignal && res.Info != nil { for call, info := range res.Info.Calls { fuzzer.triageProgCall(req.Prog, &info, call, req.flags) } @@ -249,10 +256,10 @@ func (fuzzer *Fuzzer) nextRand() int64 { } func (fuzzer *Fuzzer) pushExec(req *Request, prio priority) { - if req.NeedHints && (req.NeedCover || req.NeedSignal != rpctype.NoSignal) { + if req.NeedHints && (req.NeedCover || req.NeedSignal != NoSignal) { panic("Request.NeedHints is mutually exclusive with other fields") } - if req.SignalFilter != nil && req.NeedSignal != rpctype.NewSignal { + if req.SignalFilter != nil && req.NeedSignal != NewSignal { panic("SignalFilter must be used with NewSignal") } fuzzer.nextExec.push(&priorityQueueItem[*Request]{ diff --git a/pkg/fuzzer/fuzzer_test.go b/pkg/fuzzer/fuzzer_test.go index 6c6bb46fd..5e275851a 100644 --- a/pkg/fuzzer/fuzzer_test.go +++ b/pkg/fuzzer/fuzzer_test.go @@ -22,7 +22,6 @@ import ( "github.com/google/syzkaller/pkg/csource" "github.com/google/syzkaller/pkg/ipc" "github.com/google/syzkaller/pkg/ipc/ipcconfig" - "github.com/google/syzkaller/pkg/rpctype" "github.com/google/syzkaller/pkg/signal" "github.com/google/syzkaller/pkg/testutil" "github.com/google/syzkaller/prog" @@ -193,7 +192,7 @@ func emulateExec(req *Request) (*Result, string, error) { if req.NeedCover { callInfo.Cover = []uint32{cover} } - if req.NeedSignal != rpctype.NoSignal { + if req.NeedSignal != NoSignal { callInfo.Signal = []uint32{cover} } info.Calls = append(info.Calls, callInfo) @@ -302,7 +301,7 @@ var crashRe = regexp.MustCompile(`{{CRASH: (.*?)}}`) func (proc *executorProc) execute(req *Request) (*Result, string, error) { execOpts := proc.execOpts // TODO: it's duplicated from fuzzer.go. - if req.NeedSignal != rpctype.NoSignal { + if req.NeedSignal != NoSignal { execOpts.ExecFlags |= ipc.FlagCollectSignal } if req.NeedCover { diff --git a/pkg/fuzzer/job.go b/pkg/fuzzer/job.go index b5bb2aab1..17929fcda 100644 --- a/pkg/fuzzer/job.go +++ b/pkg/fuzzer/job.go @@ -10,7 +10,6 @@ import ( "github.com/google/syzkaller/pkg/corpus" "github.com/google/syzkaller/pkg/cover" "github.com/google/syzkaller/pkg/ipc" - "github.com/google/syzkaller/pkg/rpctype" "github.com/google/syzkaller/pkg/signal" "github.com/google/syzkaller/pkg/stats" "github.com/google/syzkaller/prog" @@ -71,7 +70,7 @@ func genProgRequest(fuzzer *Fuzzer, rnd *rand.Rand) *Request { fuzzer.ChoiceTable()) return &Request{ Prog: p, - NeedSignal: rpctype.NewSignal, + NeedSignal: NewSignal, stat: fuzzer.statExecGenerate, } } @@ -90,7 +89,7 @@ func mutateProgRequest(fuzzer *Fuzzer, rnd *rand.Rand) *Request { ) return &Request{ Prog: newP, - NeedSignal: rpctype.NewSignal, + NeedSignal: NewSignal, stat: fuzzer.statExecFuzz, } } @@ -105,7 +104,7 @@ func candidateRequest(fuzzer *Fuzzer, input Candidate) *Request { } return &Request{ Prog: input.Prog, - NeedSignal: rpctype.NewSignal, + NeedSignal: NewSignal, stat: fuzzer.statExecCandidate, flags: flags, } @@ -197,7 +196,7 @@ func (job *triageJob) deflake(exec func(job, *Request) *Result, stat *stats.Val, } result := exec(job, &Request{ Prog: job.p, - NeedSignal: rpctype.AllSignal, + NeedSignal: AllSignal, NeedCover: true, NeedRawCover: rawCover, stat: stat, @@ -238,7 +237,7 @@ func (job *triageJob) minimize(fuzzer *Fuzzer, newSignal signal.Signal) (stop bo for i := 0; i < minimizeAttempts; i++ { result := fuzzer.exec(job, &Request{ Prog: p1, - NeedSignal: rpctype.NewSignal, + NeedSignal: NewSignal, SignalFilter: newSignal, SignalFilterCall: call1, stat: fuzzer.statExecMinimize, @@ -313,7 +312,7 @@ func (job *smashJob) run(fuzzer *Fuzzer) { fuzzer.Config.Corpus.Programs()) result := fuzzer.exec(job, &Request{ Prog: p, - NeedSignal: rpctype.NewSignal, + NeedSignal: NewSignal, stat: fuzzer.statExecSmash, }) if result.Stop { @@ -404,7 +403,7 @@ func (job *hintsJob) run(fuzzer *Fuzzer) { func(p *prog.Prog) bool { result := fuzzer.exec(job, &Request{ Prog: p, - NeedSignal: rpctype.NewSignal, + NeedSignal: NewSignal, stat: fuzzer.statExecHint, }) return !result.Stop |
