diff options
| -rw-r--r-- | pkg/corpus/corpus_test.go | 4 | ||||
| -rw-r--r-- | pkg/cover/cover.go | 6 | ||||
| -rw-r--r-- | pkg/fuzzer/queue/queue.go | 9 | ||||
| -rw-r--r-- | pkg/ifuzz/powerpc/powerpc.go | 8 | ||||
| -rw-r--r-- | pkg/signal/signal.go | 20 | ||||
| -rw-r--r-- | prog/expr.go | 2 | ||||
| -rw-r--r-- | prog/prog.go | 2 | ||||
| -rw-r--r-- | prog/types.go | 4 | ||||
| -rw-r--r-- | tools/syz-testbed/html.go | 22 | ||||
| -rw-r--r-- | tools/syz-testbed/stats.go | 20 | ||||
| -rw-r--r-- | tools/syz-testbed/targets.go | 24 | ||||
| -rw-r--r-- | tools/syz-testbed/testbed.go | 2 |
12 files changed, 49 insertions, 74 deletions
diff --git a/pkg/corpus/corpus_test.go b/pkg/corpus/corpus_test.go index c4410503e..7efa386ae 100644 --- a/pkg/corpus/corpus_test.go +++ b/pkg/corpus/corpus_test.go @@ -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) } diff --git a/pkg/cover/cover.go b/pkg/cover/cover.go index caef2a09c..13bba2347 100644 --- a/pkg/cover/cover.go +++ b/pkg/cover/cover.go @@ -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 diff --git a/pkg/fuzzer/queue/queue.go b/pkg/fuzzer/queue/queue.go index 1b98d768e..37e69837f 100644 --- a/pkg/fuzzer/queue/queue.go +++ b/pkg/fuzzer/queue/queue.go @@ -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" ) @@ -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 @@ -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) { diff --git a/pkg/ifuzz/powerpc/powerpc.go b/pkg/ifuzz/powerpc/powerpc.go index 9cef453f4..7b06f2b25 100644 --- a/pkg/ifuzz/powerpc/powerpc.go +++ b/pkg/ifuzz/powerpc/powerpc.go @@ -61,7 +61,7 @@ const ( prefixOpcode = uint32(1) << prefixShift ) -func (insn Insn) isPrefixed() bool { +func (insn *Insn) isPrefixed() bool { return insn.Opcode&prefixMask == prefixOpcode } @@ -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) } @@ -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 { @@ -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) } diff --git a/pkg/signal/signal.go b/pkg/signal/signal.go index b63811fe5..506d65aac 100644 --- a/pkg/signal/signal.go +++ b/pkg/signal/signal.go @@ -9,7 +9,8 @@ type ( prioType int8 ) -type Signal map[elemType]prioType +// Signal was hard to refactor when we enabled recvcheck. +type Signal map[elemType]prioType // nolint: recvcheck func (s Signal) Len() int { return len(s) @@ -38,23 +39,6 @@ func FromRaw(raw []uint64, prio uint8) Signal { return s } -func (s Signal) Diff(s1 Signal) Signal { - if s1.Empty() { - return nil - } - var res Signal - for e, p1 := range s1 { - if p, ok := s[e]; ok && p >= p1 { - continue - } - if res == nil { - res = make(Signal) - } - res[e] = p1 - } - return res -} - func (s Signal) DiffRaw(raw []uint64, prio uint8) Signal { var res Signal for _, e := range raw { diff --git a/prog/expr.go b/prog/expr.go index 87fb056a9..fbffd3578 100644 --- a/prog/expr.go +++ b/prog/expr.go @@ -8,7 +8,7 @@ import ( "fmt" ) -func (bo *BinaryExpression) Evaluate(finder ArgFinder) (uint64, bool) { +func (bo BinaryExpression) Evaluate(finder ArgFinder) (uint64, bool) { left, ok := bo.Left.Evaluate(finder) if !ok { return 0, false diff --git a/prog/prog.go b/prog/prog.go index c9bd05baa..27b46c541 100644 --- a/prog/prog.go +++ b/prog/prog.go @@ -91,7 +91,7 @@ type ArgCommon struct { dir Dir } -func (arg ArgCommon) Type() Type { +func (arg *ArgCommon) Type() Type { if arg.ref == 0 { panic("broken type ref") } diff --git a/prog/types.go b/prog/types.go index 02bbdffdf..3a8d478ce 100644 --- a/prog/types.go +++ b/prog/types.go @@ -129,7 +129,7 @@ func (bo BinaryExpression) ForEachValue(cb func(*Value)) { bo.Right.ForEachValue(cb) } -func (bo *BinaryExpression) Clone() Expression { +func (bo BinaryExpression) Clone() Expression { return &BinaryExpression{ Operator: bo.Operator, Left: bo.Left.Clone(), @@ -144,7 +144,7 @@ type Value struct { Path []string } -func (v Value) GoString() string { +func (v *Value) GoString() string { return fmt.Sprintf("&prog.Value{%#v,%#v}", v.Value, v.Path) } diff --git a/tools/syz-testbed/html.go b/tools/syz-testbed/html.go index c28020df3..e8e2e9a22 100644 --- a/tools/syz-testbed/html.go +++ b/tools/syz-testbed/html.go @@ -145,7 +145,7 @@ const ( HTMLReproDurationTable = "repro_duration" ) -type uiTableGenerator = func(urlPrefix string, view StatView, r *http.Request) (*uiTable, error) +type uiTableGenerator = func(urlPrefix string, view *StatView, r *http.Request) (*uiTable, error) type uiTableType struct { Key string @@ -171,12 +171,12 @@ type uiMainPage struct { func (ctx *TestbedContext) getTableTypes() []uiTableType { allTypeList := []uiTableType{ {HTMLStatsTable, "Statistics", ctx.httpMainStatsTable}, - {HTMLBugsTable, "Bugs", ctx.genSimpleTableController((StatView).GenerateBugTable, true)}, - {HTMLBugCountsTable, "Bug Counts", ctx.genSimpleTableController((StatView).GenerateBugCountsTable, false)}, - {HTMLReprosTable, "Repros", ctx.genSimpleTableController((StatView).GenerateReproSuccessTable, true)}, - {HTMLCReprosTable, "C Repros", ctx.genSimpleTableController((StatView).GenerateCReproSuccessTable, true)}, - {HTMLReproAttemptsTable, "All Repros", ctx.genSimpleTableController((StatView).GenerateReproAttemptsTable, false)}, - {HTMLReproDurationTable, "Duration", ctx.genSimpleTableController((StatView).GenerateReproDurationTable, true)}, + {HTMLBugsTable, "Bugs", ctx.genSimpleTableController((*StatView).GenerateBugTable, true)}, + {HTMLBugCountsTable, "Bug Counts", ctx.genSimpleTableController((*StatView).GenerateBugCountsTable, false)}, + {HTMLReprosTable, "Repros", ctx.genSimpleTableController((*StatView).GenerateReproSuccessTable, true)}, + {HTMLCReprosTable, "C Repros", ctx.genSimpleTableController((*StatView).GenerateCReproSuccessTable, true)}, + {HTMLReproAttemptsTable, "All Repros", ctx.genSimpleTableController((*StatView).GenerateReproAttemptsTable, false)}, + {HTMLReproDurationTable, "Duration", ctx.genSimpleTableController((*StatView).GenerateReproDurationTable, true)}, } typeList := []uiTableType{} for _, t := range allTypeList { @@ -187,9 +187,9 @@ func (ctx *TestbedContext) getTableTypes() []uiTableType { return typeList } -func (ctx *TestbedContext) genSimpleTableController(method func(view StatView) (*Table, error), +func (ctx *TestbedContext) genSimpleTableController(method func(view *StatView) (*Table, error), hasFooter bool) uiTableGenerator { - return func(urlPrefix string, view StatView, r *http.Request) (*uiTable, error) { + return func(urlPrefix string, view *StatView, r *http.Request) (*uiTable, error) { table, err := method(view) if err != nil { return nil, fmt.Errorf("table generation failed: %w", err) @@ -201,7 +201,7 @@ func (ctx *TestbedContext) genSimpleTableController(method func(view StatView) ( } } -func (ctx *TestbedContext) httpMainStatsTable(urlPrefix string, view StatView, r *http.Request) (*uiTable, error) { +func (ctx *TestbedContext) httpMainStatsTable(urlPrefix string, view *StatView, r *http.Request) (*uiTable, error) { alignBy := r.FormValue("align") table, err := view.AlignedStatsTable(alignBy) if err != nil { @@ -276,7 +276,7 @@ func (ctx *TestbedContext) httpMain(w http.ResponseWriter, r *http.Request) { v.Set("table", t.Key) return "/?" + v.Encode() } - uiView.ActiveTable, err = tableType.Generator(uiView.GenTableURL(tableType)+"&", *activeView, r) + uiView.ActiveTable, err = tableType.Generator(uiView.GenTableURL(tableType)+"&", activeView, r) if err != nil { http.Error(w, fmt.Sprintf("%s", err), http.StatusInternalServerError) return diff --git a/tools/syz-testbed/stats.go b/tools/syz-testbed/stats.go index 9f338f4bb..4ac02b230 100644 --- a/tools/syz-testbed/stats.go +++ b/tools/syz-testbed/stats.go @@ -134,7 +134,7 @@ func summarizeBugs(groups []RunResultGroup) ([]*BugSummary, error) { // For each checkout, take the union of sets of bugs found by each instance. // Then output these unions as a single table. -func (view StatView) GenerateBugTable() (*Table, error) { +func (view *StatView) GenerateBugTable() (*Table, error) { table := NewTable("Bug") for _, group := range view.Groups { table.AddColumn(group.Name) @@ -153,7 +153,7 @@ func (view StatView) GenerateBugTable() (*Table, error) { return table, nil } -func (view StatView) GenerateBugCountsTable() (*Table, error) { +func (view *StatView) GenerateBugCountsTable() (*Table, error) { table := NewTable("Bug") for _, group := range view.Groups { table.AddColumn(group.Name) @@ -242,11 +242,11 @@ func (group RunResultGroup) groupLastRecord() map[string]*sample.Sample { return groupSamples(records) } -func (view StatView) StatsTable() (*Table, error) { +func (view *StatView) StatsTable() (*Table, error) { return view.AlignedStatsTable("uptime") } -func (view StatView) AlignedStatsTable(field string) (*Table, error) { +func (view *StatView) AlignedStatsTable(field string) (*Table, error) { // We assume that the stats values are nonnegative. table := NewTable("Property") if field == "" { @@ -300,7 +300,7 @@ func (view StatView) AlignedStatsTable(field string) (*Table, error) { return table, nil } -func (view StatView) InstanceStatsTable() (*Table, error) { +func (view *StatView) InstanceStatsTable() (*Table, error) { newView := StatView{} for _, group := range view.Groups { for i, result := range group.Results { @@ -314,7 +314,7 @@ func (view StatView) InstanceStatsTable() (*Table, error) { } // How often we find a repro to each crash log. -func (view StatView) GenerateReproSuccessTable() (*Table, error) { +func (view *StatView) GenerateReproSuccessTable() (*Table, error) { table := NewTable("Bug") for _, group := range view.Groups { table.AddColumn(group.Name) @@ -337,7 +337,7 @@ func (view StatView) GenerateReproSuccessTable() (*Table, error) { } // What share of found repros also have a C repro. -func (view StatView) GenerateCReproSuccessTable() (*Table, error) { +func (view *StatView) GenerateCReproSuccessTable() (*Table, error) { table := NewTable("Bug") for _, group := range view.Groups { table.AddColumn(group.Name) @@ -363,7 +363,7 @@ func (view StatView) GenerateCReproSuccessTable() (*Table, error) { } // What share of found repros also have a C repro. -func (view StatView) GenerateReproDurationTable() (*Table, error) { +func (view *StatView) GenerateReproDurationTable() (*Table, error) { table := NewTable("Bug") for _, group := range view.Groups { table.AddColumn(group.Name) @@ -389,7 +389,7 @@ func (view StatView) GenerateReproDurationTable() (*Table, error) { } // List all repro attempts. -func (view StatView) GenerateReproAttemptsTable() (*Table, error) { +func (view *StatView) GenerateReproAttemptsTable() (*Table, error) { table := NewTable("Result #", "Bug", "Checkout", "Repro found", "C repro found", "Repro title", "Duration") for gid, group := range view.Groups { for rid, result := range group.SyzReproResults() { @@ -408,7 +408,7 @@ func (view StatView) GenerateReproAttemptsTable() (*Table, error) { } // Average bench files of several instances into a single bench file. -func (group *RunResultGroup) SaveAvgBenchFile(fileName string) error { +func (group RunResultGroup) SaveAvgBenchFile(fileName string) error { f, err := os.Create(fileName) if err != nil { return err diff --git a/tools/syz-testbed/targets.go b/tools/syz-testbed/targets.go index e37791135..ede42d236 100644 --- a/tools/syz-testbed/targets.go +++ b/tools/syz-testbed/targets.go @@ -21,7 +21,7 @@ import ( // TestbedTarget represents all behavioral differences between specific testbed targets. type TestbedTarget interface { NewJob(slotName string, checkouts []*Checkout) (*Checkout, Instance, error) - SaveStatView(view StatView, dir string) error + SaveStatView(view *StatView, dir string) error SupportsHTMLView(key string) bool } @@ -130,16 +130,16 @@ func (t *SyzManagerTarget) SupportsHTMLView(key string) bool { return supported[key] } -func (t *SyzManagerTarget) SaveStatView(view StatView, dir string) error { +func (t *SyzManagerTarget) SaveStatView(view *StatView, dir string) error { benchDir := filepath.Join(dir, "benches") err := osutil.MkdirAll(benchDir) if err != nil { return fmt.Errorf("failed to create %s: %w", benchDir, err) } - tableStats := map[string]func(view StatView) (*Table, error){ - "bugs.csv": (StatView).GenerateBugTable, - "checkout_stats.csv": (StatView).StatsTable, - "instance_stats.csv": (StatView).InstanceStatsTable, + tableStats := map[string]func(view *StatView) (*Table, error){ + "bugs.csv": (*StatView).GenerateBugTable, + "checkout_stats.csv": (*StatView).StatsTable, + "instance_stats.csv": (*StatView).InstanceStatsTable, } for fileName, genFunc := range tableStats { table, err := genFunc(view) @@ -247,12 +247,12 @@ func (t *SyzReproTarget) SupportsHTMLView(key string) bool { return supported[key] } -func (t *SyzReproTarget) SaveStatView(view StatView, dir string) error { - tableStats := map[string]func(view StatView) (*Table, error){ - "repro_success.csv": (StatView).GenerateReproSuccessTable, - "crepros_success.csv": (StatView).GenerateCReproSuccessTable, - "repro_attempts.csv": (StatView).GenerateReproAttemptsTable, - "repro_duration.csv": (StatView).GenerateReproDurationTable, +func (t *SyzReproTarget) SaveStatView(view *StatView, dir string) error { + tableStats := map[string]func(view *StatView) (*Table, error){ + "repro_success.csv": (*StatView).GenerateReproSuccessTable, + "crepros_success.csv": (*StatView).GenerateCReproSuccessTable, + "repro_attempts.csv": (*StatView).GenerateReproAttemptsTable, + "repro_duration.csv": (*StatView).GenerateReproDurationTable, } for fileName, genFunc := range tableStats { table, err := genFunc(view) diff --git a/tools/syz-testbed/testbed.go b/tools/syz-testbed/testbed.go index 52e63b4be..357ff65f6 100644 --- a/tools/syz-testbed/testbed.go +++ b/tools/syz-testbed/testbed.go @@ -193,7 +193,7 @@ func (ctx *TestbedContext) SaveStats() error { } for _, view := range views { dir := filepath.Join(ctx.Config.Workdir, "stats_"+view.Name) - err := ctx.Target.SaveStatView(view, dir) + err := ctx.Target.SaveStatView(&view, dir) if err != nil { return err } |
