Skip to content

Commit

Permalink
all: fix recvcheck errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tarasmadan committed Feb 7, 2025
1 parent 352d6ba commit 6741d7c
Show file tree
Hide file tree
Showing 22 changed files with 123 additions and 122 deletions.
8 changes: 4 additions & 4 deletions pkg/corpus/corpus.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewFocusedCorpus(ctx context.Context, updates chan<- NewItemEvent, areas []
corpus.StatProgs = stat.New("corpus", "Number of test programs in the corpus", stat.Console,
stat.Link("/corpus"), stat.Graph("corpus"), stat.LenOf(&corpus.progsMap, &corpus.mu))
corpus.StatSignal = stat.New("signal", "Fuzzing signal in the corpus",
stat.LenOf(&corpus.signal, &corpus.mu))
stat.LenOf(corpus.signal.InnerMap(), &corpus.mu))
corpus.StatCover = stat.New("coverage", "Source coverage in the corpus", stat.Console,
stat.Link("/cover"), stat.Prometheus("syz_corpus_cover"), stat.LenOf(&corpus.cover, &corpus.mu))
for _, area := range areas {
Expand Down Expand Up @@ -98,7 +98,7 @@ type Item struct {
Call int
Prog *prog.Prog
HasAny bool // whether the prog contains squashed arguments
Signal signal.Signal
Signal *signal.Signal
Cover []uint64
Updates []ItemUpdate

Expand All @@ -112,7 +112,7 @@ func (item Item) StringCall() string {
type NewInput struct {
Prog *prog.Prog
Call int
Signal signal.Signal
Signal *signal.Signal
Cover []uint64
RawCover []uint64
}
Expand Down Expand Up @@ -208,7 +208,7 @@ func (corpus *Corpus) applyFocusAreas(item *Item, coverDelta []uint64) {
}
}

func (corpus *Corpus) Signal() signal.Signal {
func (corpus *Corpus) Signal() *signal.Signal {
corpus.mu.RLock()
defer corpus.mu.RUnlock()
return corpus.signal.Copy()
Expand Down
4 changes: 2 additions & 2 deletions pkg/corpus/corpus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func TestCorpusOperation(t *testing.T) {
}

// Verify the total signal.
assert.Equal(t, corpus.StatSignal.Val(), 5)
assert.Equal(t, corpus.StatProgs.Val(), 2)
assert.Equal(t, 5, corpus.StatSignal.Val())
assert.Equal(t, 2, corpus.StatProgs.Val())

corpus.Minimize(true)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/corpus/prio.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func (pl *ProgramsList) chooseProgram(r *rand.Rand) *prog.Prog {
return pl.progs[idx]
}

func (pl *ProgramsList) saveProgram(p *prog.Prog, signal signal.Signal) {
prio := int64(len(signal))
func (pl *ProgramsList) saveProgram(p *prog.Prog, signal *signal.Signal) {
prio := int64(signal.Len())
if prio == 0 {
prio = 1
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/corpus/prio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestChooseProgram(t *testing.T) {
}
inp := generateInput(target, rs, sizeSig)
corpus.Save(inp)
priorities[inp.Prog] = int64(len(inp.Signal))
priorities[inp.Prog] = int64(inp.Signal.Len())
}
counters := make(map[*prog.Prog]int)
for it := 0; it < maxIters; it++ {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cover/cover.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func (cov *Cover) MergeDiff(raw []uint64) []uint64 {
return raw[:n]
}

func (cov Cover) Serialize() []uint64 {
res := make([]uint64, 0, len(cov))
for pc := range cov {
func (cov *Cover) Serialize() []uint64 {
res := make([]uint64, 0, len(*cov))
for pc := range *cov {
res = append(res, pc)
}
return res
Expand Down
10 changes: 5 additions & 5 deletions pkg/fuzzer/cover.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
// Cover keeps track of the signal known to the fuzzer.
type Cover struct {
mu sync.RWMutex
maxSignal signal.Signal // max signal ever observed (including flakes)
newSignal signal.Signal // newly identified max signal
maxSignal *signal.Signal // max signal ever observed (including flakes)
newSignal *signal.Signal // newly identified max signal
}

func newCover() *Cover {
Expand All @@ -24,7 +24,7 @@ func newCover() *Cover {
return cover
}

func (cover *Cover) addRawMaxSignal(signal []uint64, prio uint8) signal.Signal {
func (cover *Cover) addRawMaxSignal(signal []uint64, prio uint8) *signal.Signal {
cover.mu.Lock()
defer cover.mu.Unlock()
diff := cover.maxSignal.DiffRaw(signal, prio)
Expand All @@ -36,13 +36,13 @@ func (cover *Cover) addRawMaxSignal(signal []uint64, prio uint8) signal.Signal {
return diff
}

func (cover *Cover) CopyMaxSignal() signal.Signal {
func (cover *Cover) CopyMaxSignal() *signal.Signal {
cover.mu.RLock()
defer cover.mu.RUnlock()
return cover.maxSignal.Copy()
}

func (cover *Cover) GrabSignalDelta() signal.Signal {
func (cover *Cover) GrabSignalDelta() *signal.Signal {
cover.mu.Lock()
defer cover.mu.Unlock()
plus := cover.newSignal
Expand Down
2 changes: 1 addition & 1 deletion pkg/fuzzer/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (fuzzer *Fuzzer) triageProgCall(p *prog.Prog, info *flatrpc.CallInfo, call
(*triage)[call] = &triageCall{
errno: info.Error,
newSignal: newMaxSignal,
signals: [deflakeNeedRuns]signal.Signal{signal.FromRaw(info.Signal, prio)},
signals: [deflakeNeedRuns]*signal.Signal{signal.FromRaw(info.Signal, prio)},
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/fuzzer/fuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (f *testFuzzer) OnDone(req *queue.Request, res *queue.Result) bool {
if f.iter%100 == 0 {
f.t.Logf("<iter %d>: corpus %d, signal %d, max signal %d, crash types %d, running jobs %d",
f.iter, f.fuzzer.Config.Corpus.StatProgs.Val(), f.fuzzer.Config.Corpus.StatSignal.Val(),
len(f.fuzzer.Cover.maxSignal), len(f.crashes), f.fuzzer.statJobs.Val())
f.fuzzer.Cover.maxSignal.Len(), len(f.crashes), f.fuzzer.statJobs.Val())
}
if f.iter > f.iterLimit || len(f.crashes) == len(f.expectedCrashes) {
f.done()
Expand Down
16 changes: 8 additions & 8 deletions pkg/fuzzer/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ type triageJob struct {

type triageCall struct {
errno int32
newSignal signal.Signal
newSignal *signal.Signal

// Filled after deflake:
signals [deflakeNeedRuns]signal.Signal
stableSignal signal.Signal
newStableSignal signal.Signal
signals [deflakeNeedRuns]*signal.Signal
stableSignal *signal.Signal
newStableSignal *signal.Signal
cover cover.Cover
rawCover []uint64
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func (job *triageJob) deflake(exec func(*queue.Request, ProgFlags) *queue.Result
indices := make([]int, 0, len(job.calls))
for call, info := range job.calls {
indices = append(indices, call)
totalNewSignal += len(info.newSignal)
totalNewSignal += info.newSignal.Len()
}
if job.stopDeflake(run, needRuns, prevTotalNewSignal == totalNewSignal) {
break
Expand Down Expand Up @@ -356,7 +356,7 @@ func (job *triageJob) minimize(call int, info *triageCall) (*prog.Prog, int) {
if stop {
return false
}
var mergedSignal signal.Signal
var mergedSignal *signal.Signal
for i := 0; i < minimizeAttempts; i++ {
result := job.execute(&queue.Request{
Prog: p1,
Expand Down Expand Up @@ -408,7 +408,7 @@ func reexecutionSuccess(info *flatrpc.ProgInfo, oldErrno int32, call int) bool {
return info.Extra != nil && len(info.Extra.Signal) != 0
}

func getSignalAndCover(p *prog.Prog, info *flatrpc.ProgInfo, call int) signal.Signal {
func getSignalAndCover(p *prog.Prog, info *flatrpc.ProgInfo, call int) *signal.Signal {
inf := info.Extra
if call != -1 {
inf = info.Calls[call]
Expand All @@ -419,7 +419,7 @@ func getSignalAndCover(p *prog.Prog, info *flatrpc.ProgInfo, call int) signal.Si
return signal.FromRaw(inf.Signal, signalPrio(p, inf, call))
}

func signalPreview(s signal.Signal) string {
func signalPreview(s *signal.Signal) string {
if s.Len() > 0 && s.Len() <= 3 {
var sb strings.Builder
sb.WriteString(" (")
Expand Down
9 changes: 0 additions & 9 deletions pkg/fuzzer/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/google/syzkaller/pkg/flatrpc"
"github.com/google/syzkaller/pkg/hash"
"github.com/google/syzkaller/pkg/signal"
"github.com/google/syzkaller/pkg/stat"
"github.com/google/syzkaller/prog"
)
Expand All @@ -32,11 +31,6 @@ type Request struct {
BinaryFile string // for RequestTypeBinary
GlobPattern string // for RequestTypeGlob

// If specified, the resulting signal for call SignalFilterCall
// will include subset of it even if it's not new.
SignalFilter signal.Signal
SignalFilterCall int

// Return all signal for these calls instead of new signal.
ReturnAllSignal []int
ReturnError bool
Expand Down Expand Up @@ -123,9 +117,6 @@ func (r *Request) Validate() error {
if len(r.ReturnAllSignal) != 0 && !collectSignal {
return fmt.Errorf("ReturnAllSignal is set, but FlagCollectSignal is not")
}
if r.SignalFilter != nil && !collectSignal {
return fmt.Errorf("SignalFilter must be used with FlagCollectSignal")
}
collectComps := r.ExecOpts.ExecFlags&flatrpc.ExecFlagCollectComps > 0
collectCover := r.ExecOpts.ExecFlags&flatrpc.ExecFlagCollectCover > 0
if (collectComps) && (collectSignal || collectCover) {
Expand Down
8 changes: 4 additions & 4 deletions pkg/ifuzz/powerpc/powerpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const (
prefixOpcode = uint32(1) << prefixShift
)

func (insn Insn) isPrefixed() bool {
func (insn *Insn) isPrefixed() bool {
return insn.Opcode&prefixMask == prefixOpcode
}

Expand Down Expand Up @@ -119,7 +119,7 @@ func encodeBits(n uint, ff []InsnBits) uint32 {
return ret
}

func (insn Insn) Encode(cfg *iset.Config, r *rand.Rand) []byte {
func (insn *Insn) Encode(cfg *iset.Config, r *rand.Rand) []byte {
if insn.Pseudo {
return insn.generator(cfg, r)
}
Expand All @@ -132,7 +132,7 @@ func (insn Insn) Encode(cfg *iset.Config, r *rand.Rand) []byte {
return ret
}

func (insn Insn) encodeOpcode(cfg *iset.Config, r *rand.Rand, opcode, mask uint32, f []InsnField) []byte {
func (insn *Insn) encodeOpcode(cfg *iset.Config, r *rand.Rand, opcode, mask uint32, f []InsnField) []byte {
ret := make([]byte, 0)
insn32 := opcode
if len(cfg.MemRegions) != 0 {
Expand Down Expand Up @@ -179,7 +179,7 @@ func (insn *Insn) Info() (string, iset.Mode, bool, bool) {
return insn.Name, insn.mode(), insn.Pseudo, insn.Priv
}

func (insn Insn) mode() iset.Mode {
func (insn *Insn) mode() iset.Mode {
return (1 << iset.ModeLong64) | (1 << iset.ModeProt32)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/manager/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (kc *kernelContext) Loop() error {
return eg.Wait()
}

func (kc *kernelContext) MaxSignal() signal.Signal {
func (kc *kernelContext) MaxSignal() *signal.Signal {
if fuzzer := kc.fuzzer.Load(); fuzzer != nil {
return fuzzer.Cover.CopyMaxSignal()
}
Expand Down Expand Up @@ -411,7 +411,7 @@ func (kc *kernelContext) setupFuzzer(features flatrpc.Feature, syscalls map[*pro
return
}
newSignal := fuzzerObj.Cover.GrabSignalDelta()
if len(newSignal) == 0 {
if newSignal.Len() == 0 {
continue
}
kc.serv.DistributeSignalDelta(newSignal)
Expand Down
4 changes: 2 additions & 2 deletions pkg/manager/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ func (serv *HTTPServer) httpCoverFallback(w http.ResponseWriter, r *http.Request
return
}
calls := make(map[int][]int)
for s := range corpus.Signal() {
id, errno := prog.DecodeFallbackSignal(uint64(s))
for s := range *corpus.Signal().InnerMap() {
id, errno := prog.DecodeFallbackSignal(s)
calls[id] = append(calls[id], errno)
}
data := &UIFallbackCoverData{
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpcserver/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (ctx *local) BugFrames() ([]string, []string) {
return nil, nil
}

func (ctx *local) MaxSignal() signal.Signal {
func (ctx *local) MaxSignal() *signal.Signal {
return signal.FromRaw(ctx.cfg.MaxSignal, 0)
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/rpcserver/mocks/Manager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/rpcserver/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type RemoteConfig struct {

//go:generate ../../tools/mockery.sh --name Manager --output ./mocks
type Manager interface {
MaxSignal() signal.Signal
MaxSignal() *signal.Signal
BugFrames() (leaks []string, races []string)
MachineChecked(features flatrpc.Feature, syscalls map[*prog.Syscall]bool) (queue.Source, error)
CoverageFilter(modules []*vminfo.KernelModule) ([]uint64, error)
Expand All @@ -80,7 +80,7 @@ type Server interface {
CreateInstance(id int, injectExec chan<- bool, updInfo dispatcher.UpdateInfo) chan error
ShutdownInstance(id int, crashed bool, extraExecs ...report.ExecutorInfo) ([]ExecRecord, []byte)
StopFuzzing(id int)
DistributeSignalDelta(plus signal.Signal)
DistributeSignalDelta(plus *signal.Signal)
}

type server struct {
Expand Down Expand Up @@ -564,7 +564,7 @@ func (serv *server) ShutdownInstance(id int, crashed bool, extraExecs ...report.
return runner.Shutdown(crashed, extraExecs...), runner.MachineInfo()
}

func (serv *server) DistributeSignalDelta(plus signal.Signal) {
func (serv *server) DistributeSignalDelta(plus *signal.Signal) {
plusRaw := plus.ToRaw()
serv.foreachRunnerAsync(func(runner *Runner) {
runner.SendSignalUpdate(plusRaw)
Expand Down
Loading

0 comments on commit 6741d7c

Please sign in to comment.