aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dashboard/app/admin.go2
-rw-r--r--dashboard/app/api.go16
-rw-r--r--dashboard/app/config_stub.go12
-rw-r--r--dashboard/app/email_test.go2
-rw-r--r--dashboard/app/entities.go2
-rw-r--r--dashboard/app/handler.go6
-rw-r--r--dashboard/app/jobs.go8
-rw-r--r--dashboard/app/reporting_email.go6
-rw-r--r--dashboard/dashapi/dashapi.go2
-rw-r--r--executor/syscalls_linux.h10
-rw-r--r--executor/test.go8
-rw-r--r--pkg/ast/parser.go8
-rw-r--r--pkg/ast/test_util.go2
-rw-r--r--pkg/compiler/check.go20
-rw-r--r--pkg/compiler/compiler.go2
-rw-r--r--pkg/compiler/types.go28
-rw-r--r--pkg/config/config.go2
-rw-r--r--pkg/cover/cover.go12
-rw-r--r--pkg/csource/build.go6
-rw-r--r--pkg/csource/common.go2
-rw-r--r--pkg/csource/csource_test.go2
-rw-r--r--pkg/email/parser_test.go3
-rw-r--r--pkg/email/patch_test.go2
-rw-r--r--pkg/gcs/gcs.go6
-rw-r--r--pkg/git/git.go2
-rw-r--r--pkg/host/host_linux.go2
-rw-r--r--pkg/ifuzz/encode.go2
-rw-r--r--pkg/ifuzz/gen/gen.go2
-rw-r--r--pkg/ipc/ipc.go11
-rw-r--r--pkg/ipc/ipc_test.go10
-rw-r--r--pkg/kernel/kernel.go6
-rw-r--r--pkg/kernel/kernel_test.go2
-rw-r--r--pkg/osutil/fileutil_test.go17
-rw-r--r--pkg/report/linux.go10
-rw-r--r--pkg/report/report.go14
-rw-r--r--pkg/repro/repro.go6
-rw-r--r--pkg/repro/repro_test.go6
-rw-r--r--pkg/rpctype/rpc.go24
-rw-r--r--pkg/rpctype/rpctype.go14
-rw-r--r--pkg/serializer/serializer.go4
-rw-r--r--pkg/serializer/serializer_test.go2
-rw-r--r--pkg/signal/signal.go18
-rw-r--r--pkg/symbolizer/nm.go2
-rw-r--r--pkg/symbolizer/symbolizer_test.go13
-rw-r--r--prog/any.go68
-rw-r--r--prog/encoding.go4
-rw-r--r--prog/minimization.go10
-rw-r--r--prog/prog.go44
-rw-r--r--prog/rand.go4
-rw-r--r--prog/resources.go2
-rw-r--r--prog/size.go3
-rw-r--r--prog/size_test.go2
-rw-r--r--prog/target.go2
-rw-r--r--prog/validation.go4
-rw-r--r--sys/freebsd/init.go3
-rw-r--r--sys/linux/386.go4
-rw-r--r--sys/linux/amd64.go4
-rw-r--r--sys/linux/arm.go4
-rw-r--r--sys/linux/arm64.go4
-rw-r--r--sys/linux/init_alg_test.go2
-rw-r--r--sys/linux/init_iptables.go3
-rw-r--r--sys/linux/ppc64le.go4
-rw-r--r--sys/linux/vnet.txt2
-rw-r--r--sys/netbsd/init.go3
-rw-r--r--sys/sys.go1
-rw-r--r--sys/syz-extract/linux.go10
-rw-r--r--sys/syz-sysgen/sysgen.go7
-rw-r--r--syz-ci/jobs.go2
-rw-r--r--syz-ci/manager.go4
-rw-r--r--syz-ci/syz-ci.go4
-rw-r--r--syz-ci/testing.go1
-rw-r--r--syz-fuzzer/fuzzer.go14
-rw-r--r--syz-fuzzer/fuzzer_linux.go4
-rw-r--r--syz-fuzzer/proc.go2
-rw-r--r--syz-hub/http.go2
-rw-r--r--syz-hub/hub.go8
-rw-r--r--syz-manager/cover.go20
-rw-r--r--syz-manager/html.go10
-rw-r--r--syz-manager/manager.go51
-rw-r--r--syz-manager/mgrconfig/mgrconfig.go20
-rw-r--r--tools/syz-crush/crush.go1
-rw-r--r--tools/syz-execprog/execprog.go2
-rw-r--r--vm/adb/adb.go15
-rw-r--r--vm/gce/gce.go16
-rw-r--r--vm/isolated/isolated.go20
-rw-r--r--vm/kvm/kvm.go12
-rw-r--r--vm/qemu/qemu.go24
-rw-r--r--vm/vm.go9
-rw-r--r--vm/vmimpl/merger_test.go2
-rw-r--r--vm/vmimpl/vmimpl.go8
90 files changed, 351 insertions, 430 deletions
diff --git a/dashboard/app/admin.go b/dashboard/app/admin.go
index 74b9a4591..40895f4e7 100644
--- a/dashboard/app/admin.go
+++ b/dashboard/app/admin.go
@@ -79,6 +79,8 @@ func dropNamespace(c context.Context, w http.ResponseWriter, r *http.Request) er
return nil
}
+var _ = dropNamespace // prevent warnings about dead code
+
func dropNamespaceReportingState(c context.Context, w http.ResponseWriter, ns string, dryRun bool) error {
tx := func(c context.Context) error {
state, err := loadReportingState(c)
diff --git a/dashboard/app/api.go b/dashboard/app/api.go
index 02ac5e0c5..e1c44fd6d 100644
--- a/dashboard/app/api.go
+++ b/dashboard/app/api.go
@@ -671,13 +671,11 @@ func apiReportFailedRepro(c context.Context, ns string, r *http.Request, payload
}
return nil
}
- if err := datastore.RunInTransaction(c, tx, &datastore.TransactionOptions{
+ err = datastore.RunInTransaction(c, tx, &datastore.TransactionOptions{
XG: true,
Attempts: 30,
- }); err != nil {
- return nil, err
- }
- return nil, nil
+ })
+ return nil, err
}
func apiNeedRepro(c context.Context, ns string, r *http.Request, payload []byte) (interface{}, error) {
@@ -712,7 +710,7 @@ func apiManagerStats(c context.Context, ns string, r *http.Request, payload []by
return nil, fmt.Errorf("failed to unmarshal request: %v", err)
}
now := timeNow(c)
- if err := updateManager(c, ns, req.Name, func(mgr *Manager, stats *ManagerStats) {
+ err := updateManager(c, ns, req.Name, func(mgr *Manager, stats *ManagerStats) {
mgr.Link = req.Addr
mgr.LastAlive = now
mgr.CurrentUpTime = req.UpTime
@@ -725,10 +723,8 @@ func apiManagerStats(c context.Context, ns string, r *http.Request, payload []by
stats.TotalFuzzingTime += req.FuzzingTime
stats.TotalCrashes += int64(req.Crashes)
stats.TotalExecs += int64(req.Execs)
- }); err != nil {
- return nil, err
- }
- return nil, nil
+ })
+ return nil, err
}
func findBugForCrash(c context.Context, ns, title string) (*Bug, *datastore.Key, error) {
diff --git a/dashboard/app/config_stub.go b/dashboard/app/config_stub.go
index 0c68453a8..dc7f3b6c5 100644
--- a/dashboard/app/config_stub.go
+++ b/dashboard/app/config_stub.go
@@ -13,7 +13,8 @@ import "time"
// See an example below.
var config GlobalConfig
-var example = GlobalConfig{
+// Example config:
+var _ = GlobalConfig{
Namespaces: map[string]*Config{
"upstream": &Config{
Key: "123",
@@ -26,11 +27,20 @@ var example = GlobalConfig{
Reporting{
Name: "upstream",
DailyLimit: 10,
+ Filter: reportAllFilter,
Config: &EmailConfig{
Email: "syzkaller@googlegroups.com",
MailMaintainers: true,
},
},
+ Reporting{
+ Name: "another",
+ Filter: reportSkipFilter,
+ },
+ Reporting{
+ Name: "yetanother",
+ Filter: reportHoldFilter,
+ },
},
},
},
diff --git a/dashboard/app/email_test.go b/dashboard/app/email_test.go
index 56d263c63..6ce4a5b7a 100644
--- a/dashboard/app/email_test.go
+++ b/dashboard/app/email_test.go
@@ -26,7 +26,7 @@ func TestEmailReport(t *testing.T) {
c.expectOK(c.API(client2, key2, "report_crash", crash, nil))
// Report the crash over email and check all fields.
- sender0, extBugID0, body0 := "", "", ""
+ var sender0, extBugID0, body0 string
{
c.expectOK(c.GET("/email_poll"))
c.expectEQ(len(c.emailSink), 1)
diff --git a/dashboard/app/entities.go b/dashboard/app/entities.go
index 6c1bcf729..25bbba5fd 100644
--- a/dashboard/app/entities.go
+++ b/dashboard/app/entities.go
@@ -296,7 +296,7 @@ func (bug *Bug) displayTitle() string {
return fmt.Sprintf("%v (%v)", bug.Title, bug.Seq+1)
}
-var displayTitleRe = regexp.MustCompile("^(.*) \\(([0-9]+)\\)$")
+var displayTitleRe = regexp.MustCompile(`^(.*) \(([0-9]+)\)$`)
func splitDisplayTitle(display string) (string, int64, error) {
match := displayTitleRe.FindStringSubmatchIndex(display)
diff --git a/dashboard/app/handler.go b/dashboard/app/handler.go
index 4ba92d4d0..f31b68b5e 100644
--- a/dashboard/app/handler.go
+++ b/dashboard/app/handler.go
@@ -31,7 +31,7 @@ func handleContext(fn contextHandler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if err := fn(c, w, r); err != nil {
- if err == AccessError {
+ if err == ErrAccess {
w.WriteHeader(http.StatusForbidden)
loginLink := ""
if user.Current(c) == nil {
@@ -61,7 +61,7 @@ func handleAuth(fn contextHandler) contextHandler {
}
}
-var AccessError = errors.New("unauthorized")
+var ErrAccess = errors.New("unauthorized")
func checkAccessLevel(c context.Context, r *http.Request, level AccessLevel) error {
if accessLevel(c, r) >= level {
@@ -72,7 +72,7 @@ func checkAccessLevel(c context.Context, r *http.Request, level AccessLevel) err
userID = fmt.Sprintf("%q [%q]", u.Email, u.AuthDomain)
}
log.Errorf(c, "unauthorized access: %v access level %v", userID, level)
- return AccessError
+ return ErrAccess
}
func accessLevel(c context.Context, r *http.Request) AccessLevel {
diff --git a/dashboard/app/jobs.go b/dashboard/app/jobs.go
index d53062d92..4461c682f 100644
--- a/dashboard/app/jobs.go
+++ b/dashboard/app/jobs.go
@@ -59,7 +59,7 @@ func handleTestRequest(c context.Context, bugID, user, extID, link, patch, repo,
merged := email.MergeEmailLists(bugCC, jobCC)
bugReporting.CC = strings.Join(merged, "|")
if _, err := datastore.Put(c, bugKey, bug); err != nil {
- return err
+ return fmt.Errorf("failed to put bug: %v", err)
}
return nil
}
@@ -152,7 +152,7 @@ func addTestJob(c context.Context, bug *Bug, bugKey *datastore.Key, bugReporting
}
job.Link = link
if _, err := datastore.Put(c, jobKey, job); err != nil {
- return err
+ return fmt.Errorf("failed to put job: %v", err)
}
return nil
}
@@ -286,7 +286,7 @@ func doneJob(c context.Context, req *dashapi.JobDoneReq) error {
job.CrashTitle = req.CrashTitle
job.Finished = now
if _, err := datastore.Put(c, jobKey, job); err != nil {
- return err
+ return fmt.Errorf("failed to put job: %v", err)
}
return nil
}
@@ -404,7 +404,7 @@ func jobReported(c context.Context, jobID string) error {
}
job.Reported = true
if _, err := datastore.Put(c, jobKey, job); err != nil {
- return err
+ return fmt.Errorf("failed to put job: %v", err)
}
return nil
}
diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go
index bb2931325..e2331e4b8 100644
--- a/dashboard/app/reporting_email.go
+++ b/dashboard/app/reporting_email.go
@@ -256,11 +256,7 @@ func emailReport(c context.Context, rep *dashapi.BugReport, templ string) error
HappenedOn: rep.HappenedOn,
}
log.Infof(c, "sending email %q to %q", rep.Title, to)
- err = sendMailTemplate(c, rep.Title, from, to, rep.ExtID, attachments, templ, data)
- if err != nil {
- return err
- }
- return nil
+ return sendMailTemplate(c, rep.Title, from, to, rep.ExtID, attachments, templ, data)
}
// handleIncomingMail is the entry point for incoming emails.
diff --git a/dashboard/dashapi/dashapi.go b/dashboard/dashapi/dashapi.go
index 080546343..1097e9065 100644
--- a/dashboard/dashapi/dashapi.go
+++ b/dashboard/dashapi/dashapi.go
@@ -166,7 +166,7 @@ func (dash *Dashboard) ReportCrash(crash *Crash) (*ReportCrashResp, error) {
return resp, err
}
-// CrashID is a short summary of a crash for repro queires.
+// CrashID is a short summary of a crash for repro queries.
type CrashID struct {
BuildID string
Title string
diff --git a/executor/syscalls_linux.h b/executor/syscalls_linux.h
index 193e7f6e9..28c524f91 100644
--- a/executor/syscalls_linux.h
+++ b/executor/syscalls_linux.h
@@ -2,7 +2,7 @@
#if defined(__i386__) || 0
#define GOARCH "386"
-#define SYZ_REVISION "a4d19f3d89c6652e30a30a8f16bb22eedea9571e"
+#define SYZ_REVISION "8a515582f716e47c7187d6acd9ef3c3e8b30a7f9"
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
@@ -1623,7 +1623,7 @@ call_t syscalls[] = {
#if defined(__x86_64__) || 0
#define GOARCH "amd64"
-#define SYZ_REVISION "0a160a2283a1e3ba08b37705ee1dbb6670b86af6"
+#define SYZ_REVISION "d701f2a2142a12c08b17afbc15110c24f09bf0da"
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
@@ -3296,7 +3296,7 @@ call_t syscalls[] = {
#if defined(__arm__) || 0
#define GOARCH "arm"
-#define SYZ_REVISION "8f884a3256f4d0f2a84807391e479e7713ba6fac"
+#define SYZ_REVISION "28772c035814f22d291032fc0d3a14c1ea6d4d34"
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
@@ -4914,7 +4914,7 @@ call_t syscalls[] = {
#if defined(__aarch64__) || 0
#define GOARCH "arm64"
-#define SYZ_REVISION "a227f9eaa7342c1fc70e2518d7d2637f13f704b8"
+#define SYZ_REVISION "32119668c79bbf78e86ee2739b37d2d06b458ff6"
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
@@ -6516,7 +6516,7 @@ call_t syscalls[] = {
#if defined(__ppc64__) || defined(__PPC64__) || defined(__powerpc64__) || 0
#define GOARCH "ppc64le"
-#define SYZ_REVISION "0a6ad6424c9561f4fddaeab2c50b92213fd76f79"
+#define SYZ_REVISION "83087ab2eb13cc0b1b58ad876c88d5c0920863c7"
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
diff --git a/executor/test.go b/executor/test.go
index 7bab3933c..f318b5627 100644
--- a/executor/test.go
+++ b/executor/test.go
@@ -28,3 +28,11 @@ func testCsumInetAcc() int {
func testKVM() int {
return int(C.test_kvm())
}
+
+// Prevent deadcode warnings:
+var (
+ _ = testCopyin
+ _ = testCsumInet
+ _ = testCsumInetAcc
+ _ = testKVM
+)
diff --git a/pkg/ast/parser.go b/pkg/ast/parser.go
index b28658de8..fb3327223 100644
--- a/pkg/ast/parser.go
+++ b/pkg/ast/parser.go
@@ -88,13 +88,13 @@ type parser struct {
}
// Skip parsing till the next NEWLINE, for error recovery.
-var skipLine = errors.New("")
+var errSkipLine = errors.New("")
func (p *parser) parseTopRecover() Node {
defer func() {
switch err := recover(); err {
case nil:
- case skipLine:
+ case errSkipLine:
// Try to recover by consuming everything until next NEWLINE.
for p.tok != tokNewLine && p.tok != tokEOF {
p.next()
@@ -143,7 +143,7 @@ func (p *parser) parseTop() Node {
}
case tokIllegal:
// Scanner has already producer an error for this one.
- panic(skipLine)
+ panic(errSkipLine)
default:
p.expect(tokComment, tokDefine, tokInclude, tokResource, tokIdent)
}
@@ -178,7 +178,7 @@ func (p *parser) expect(tokens ...token) {
str = append(str, tok.String())
}
p.s.Error(p.pos, fmt.Sprintf("unexpected %v, expecting %v", p.tok, strings.Join(str, ", ")))
- panic(skipLine)
+ panic(errSkipLine)
}
func (p *parser) parseComment() *Comment {
diff --git a/pkg/ast/test_util.go b/pkg/ast/test_util.go
index fbec645b7..3ffefcccb 100644
--- a/pkg/ast/test_util.go
+++ b/pkg/ast/test_util.go
@@ -61,7 +61,7 @@ func NewErrorMatcher(t *testing.T, file string) *ErrorMatcher {
}
}
-var errorLocationRe = regexp.MustCompile("at [a-z][a-z0-9]+\\.txt:[0-9]+:[0-9]+")
+var errorLocationRe = regexp.MustCompile(`at [a-z][a-z0-9]+\.txt:[0-9]+:[0-9]+`)
func (em *ErrorMatcher) ErrorHandler(pos Pos, msg string) {
if match := errorLocationRe.FindStringSubmatchIndex(msg); match != nil {
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go
index 4dac37260..6d304d26b 100644
--- a/pkg/compiler/check.go
+++ b/pkg/compiler/check.go
@@ -578,11 +578,11 @@ func (comp *compiler) checkStruct(ctx checkCtx, n *ast.Struct) {
type checkFlags int
const (
- checkIsArg checkFlags = 1 << iota // immidiate syscall arg type
- checkIsRet // immidiate syscall ret type
- checkIsStruct // immidiate struct field type
- checkIsResourceBase // immidiate resource base type
- checkIsTypedef // immidiate type alias/template type
+ checkIsArg checkFlags = 1 << iota // immediate syscall arg type
+ checkIsRet // immediate syscall ret type
+ checkIsStruct // immediate struct field type
+ checkIsResourceBase // immediate resource base type
+ checkIsTypedef // immediate type alias/template type
)
type checkCtx struct {
@@ -603,7 +603,7 @@ func (comp *compiler) checkType(ctx checkCtx, t *ast.Type, flags checkFlags) {
err0 := comp.errors
// Replace t with type alias/template target type inplace,
// and check the replaced type recursively.
- comp.replaceTypedef(&ctx, t, desc, flags)
+ comp.replaceTypedef(&ctx, t, flags)
if err0 == comp.errors {
comp.checkType(ctx, t, flags)
}
@@ -682,7 +682,7 @@ func (comp *compiler) checkType(ctx checkCtx, t *ast.Type, flags checkFlags) {
}
}
-func (comp *compiler) replaceTypedef(ctx *checkCtx, t *ast.Type, desc *typeDesc, flags checkFlags) {
+func (comp *compiler) replaceTypedef(ctx *checkCtx, t *ast.Type, flags checkFlags) {
typedefName := t.Ident
if t.HasColon {
comp.error(t.Pos, "type alias %v with ':'", t.Ident)
@@ -740,7 +740,7 @@ func (comp *compiler) replaceTypedef(ctx *checkCtx, t *ast.Type, desc *typeDesc,
t.Pos = pos0
// Remove base type if it's not needed in this context.
- desc = comp.getTypeDesc(t)
+ desc := comp.getTypeDesc(t)
if flags&checkIsArg != 0 && desc.NeedBase {
baseTypePos := len(t.Args) - 1
if t.Args[baseTypePos].Ident == "opt" {
@@ -938,7 +938,9 @@ func (comp *compiler) checkDupConsts() {
// The second one is meant to be const[BAR],
// Unfortunately, this does not fully work as it detects lots of false positives.
// But was useful to find real bugs as well. So for now it's disabled, but can be run manually.
- return
+ if true {
+ return
+ }
dups := make(map[string]map[string]dupConstArg)
for _, decl := range comp.desc.Nodes {
switch n := decl.(type) {
diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go
index f0d1176e7..f1e39b269 100644
--- a/pkg/compiler/compiler.go
+++ b/pkg/compiler/compiler.go
@@ -27,7 +27,7 @@ import (
// 4.1. assignSyscallNumbers: uses consts to assign syscall numbers.
// This step also detects unsupported syscalls and discards no longer
// needed AST nodes (inlcude, define, comments, etc).
-// 4.2. patchConsts: patches Int nodes refering to consts with corresponding values.
+// 4.2. patchConsts: patches Int nodes referring to consts with corresponding values.
// Also detects unsupported syscalls, structs, resources due to missing consts.
// 4.3. check: does extensive semantical checks of AST.
// 4.4. gen: generates prog objects from AST.
diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go
index f5ec1221e..019b734dd 100644
--- a/pkg/compiler/types.go
+++ b/pkg/compiler/types.go
@@ -267,10 +267,7 @@ var typeFilename = &typeDesc{
OptArgs: 1,
Args: []namedArg{{"size", typeArgInt}},
Varlen: func(comp *compiler, t *ast.Type, args []*ast.Type) bool {
- if len(args) >= 1 {
- return false
- }
- return true
+ return len(args) == 0
},
Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type {
base.TypeSize = 0
@@ -448,13 +445,17 @@ var typeBuffer = &typeDesc{
},
}
+const (
+ stringnoz = "stringnoz"
+)
+
var typeString = &typeDesc{
- Names: []string{"string", "stringnoz"},
+ Names: []string{"string", stringnoz},
CanBeTypedef: true,
OptArgs: 2,
Args: []namedArg{{"literal or flags", typeArgStringFlags}, {"size", typeArgInt}},
Check: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) {
- if t.Ident == "stringnoz" && len(args) > 1 {
+ if t.Ident == stringnoz && len(args) > 1 {
comp.error(args[0].Pos, "fixed-size string can't be non-zero-terminated")
}
},
@@ -491,7 +492,7 @@ var typeString = &typeDesc{
Kind: prog.BufferString,
SubKind: subkind,
Values: vals,
- NoZ: t.Ident == "stringnoz",
+ NoZ: t.Ident == stringnoz,
}
},
}
@@ -505,7 +506,7 @@ func (comp *compiler) genStrings(t *ast.Type, args []*ast.Type) []string {
vals = genStrArray(comp.strFlags[args[0].Ident].Values)
}
}
- if t.Ident == "stringnoz" {
+ if t.Ident == stringnoz {
return vals
}
var size uint64
@@ -645,12 +646,11 @@ func init() {
FldName: base.FldName,
StructDesc: desc,
}
- } else {
- return &prog.StructType{
- Key: key,
- FldName: base.FldName,
- StructDesc: desc,
- }
+ }
+ return &prog.StructType{
+ Key: key,
+ FldName: base.FldName,
+ StructDesc: desc,
}
}
}
diff --git a/pkg/config/config.go b/pkg/config/config.go
index b80e03b3f..f4863916d 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -110,7 +110,7 @@ func checkUnknownFieldsStruct(val interface{}, prefix string, typ reflect.Type)
}
inner, err := json.Marshal(val)
if err != nil {
- return fmt.Errorf("failed to marshal inner struct '%v%v':", prefix, err)
+ return fmt.Errorf("failed to marshal inner struct %q: %v", prefix, err)
}
return checkUnknownFieldsRec(inner, prefix, typ)
}
diff --git a/pkg/cover/cover.go b/pkg/cover/cover.go
index 367f68d4d..43b243b4b 100644
--- a/pkg/cover/cover.go
+++ b/pkg/cover/cover.go
@@ -6,14 +6,14 @@ package cover
type Cover map[uint32]struct{}
-func (covp *Cover) Merge(raw []uint32) {
- cov := *covp
- if cov == nil {
- cov = make(Cover)
- *covp = cov
+func (cov *Cover) Merge(raw []uint32) {
+ c := *cov
+ if c == nil {
+ c = make(Cover)
+ *cov = c
}
for _, pc := range raw {
- cov[pc] = struct{}{}
+ c[pc] = struct{}{}
}
}
diff --git a/pkg/csource/build.go b/pkg/csource/build.go
index 69f5adfcb..b027b337f 100644
--- a/pkg/csource/build.go
+++ b/pkg/csource/build.go
@@ -27,7 +27,7 @@ func Build(target *prog.Target, lang, src string) (string, error) {
sysTarget := targets.List[target.OS][target.Arch]
compiler := sysTarget.CCompilerPrefix + "gcc"
if _, err := exec.LookPath(compiler); err != nil {
- return "", NoCompilerErr
+ return "", ErrNoCompiler
}
flags := []string{
"-x", lang, "-Wall", "-Werror", "-O1", "-g", "-o", bin.Name(),
@@ -46,13 +46,13 @@ func Build(target *prog.Target, lang, src string) (string, error) {
if err != nil {
os.Remove(bin.Name())
data, _ := ioutil.ReadFile(src)
- return "", fmt.Errorf("failed to build program:\n%s\n%s\ncompiler invocation: %v %v\n",
+ return "", fmt.Errorf("failed to build program:\n%s\n%s\ncompiler invocation: %v %v",
data, out, compiler, flags)
}
return bin.Name(), nil
}
-var NoCompilerErr = errors.New("no target compiler")
+var ErrNoCompiler = errors.New("no target compiler")
// Format reformats C source using clang-format.
func Format(src []byte) ([]byte, error) {
diff --git a/pkg/csource/common.go b/pkg/csource/common.go
index dd13e53bf..f77df3459 100644
--- a/pkg/csource/common.go
+++ b/pkg/csource/common.go
@@ -33,7 +33,7 @@ func createCommonHeader(p *prog.Prog, opts Options) ([]byte, error) {
cmd.Stderr = stderr
cmd.Stdout = stdout
if err := cmd.Run(); len(stdout.Bytes()) == 0 {
- return nil, fmt.Errorf("cpp failed: %v\n%v\n%v\n", err, stdout.String(), stderr.String())
+ return nil, fmt.Errorf("cpp failed: %v\n%v\n%v", err, stdout.String(), stderr.String())
}
src, err := removeSystemDefines(stdout.Bytes(), defines)
diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go
index 4aaaa3451..fa5eee58a 100644
--- a/pkg/csource/csource_test.go
+++ b/pkg/csource/csource_test.go
@@ -114,7 +114,7 @@ func testOne(t *testing.T, p *prog.Prog, opts Options) {
}
defer os.Remove(srcf)
bin, err := Build(p.Target, "c", srcf)
- if err == NoCompilerErr {
+ if err == ErrNoCompiler {
t.Skip(err)
}
if err != nil {
diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go
index 69e237806..a99ab17f6 100644
--- a/pkg/email/parser_test.go
+++ b/pkg/email/parser_test.go
@@ -91,6 +91,9 @@ func TestAddAddrContextEmptyName(t *testing.T) {
t.Fatalf("want: %q, got %q", want, email1)
}
email2, context1, err := RemoveAddrContext(email1)
+ if err != nil {
+ t.Fatal(err)
+ }
if email != email2 {
t.Fatalf("want: %q, got %q", email, email2)
}
diff --git a/pkg/email/patch_test.go b/pkg/email/patch_test.go
index b10211ff0..c8cae4621 100644
--- a/pkg/email/patch_test.go
+++ b/pkg/email/patch_test.go
@@ -157,7 +157,7 @@ The handling of the might_cancel queueing is not properly protected, so
parallel operations on the file descriptor can race with each other and
lead to list corruptions or use after free.
-Protect the context for these operations with a seperate lock.
+Protect the context for these operations with a separate lock.
Reported-by: Foo Bar <foo@bar.com>
Signed-off-by: Foo Bar <foo@bar.com>
diff --git a/pkg/gcs/gcs.go b/pkg/gcs/gcs.go
index 97883256a..7e832de41 100644
--- a/pkg/gcs/gcs.go
+++ b/pkg/gcs/gcs.go
@@ -92,10 +92,8 @@ func (client *Client) UploadFile(localFile, gcsFile string) error {
}
defer w.Close()
- if _, err := io.Copy(w, local); err != nil {
- return err
- }
- return nil
+ _, err = io.Copy(w, local)
+ return err
}
func (client *Client) FileWriter(gcsFile string) (io.WriteCloser, error) {
diff --git a/pkg/git/git.go b/pkg/git/git.go
index 2455a1ea2..372309634 100644
--- a/pkg/git/git.go
+++ b/pkg/git/git.go
@@ -322,7 +322,7 @@ func CheckRepoAddress(repo string) bool {
return gitRepoRe.MatchString(repo)
}
-var gitRepoRe = regexp.MustCompile("^(git|ssh|http|https|ftp|ftps)://[a-zA-Z0-9-_]+(\\.[a-zA-Z0-9-_]+)+(:[0-9]+)?/[a-zA-Z0-9-_./]+\\.git(/)?$")
+var gitRepoRe = regexp.MustCompile(`^(git|ssh|http|https|ftp|ftps)://[a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)+(:[0-9]+)?/[a-zA-Z0-9-_./]+\.git(/)?$`)
// CheckBranch does a best-effort approximate check of a git branch name.
func CheckBranch(branch string) bool {
diff --git a/pkg/host/host_linux.go b/pkg/host/host_linux.go
index 57ce3e79e..0d1cd9afc 100644
--- a/pkg/host/host_linux.go
+++ b/pkg/host/host_linux.go
@@ -55,7 +55,7 @@ func isSupported(sandbox string, kallsyms []byte, c *prog.Syscall) bool {
if newname := kallsymsMap[name]; newname != "" {
name = newname
}
- return bytes.Index(kallsyms, []byte(" T sys_"+name+"\n")) != -1
+ return bytes.Contains(kallsyms, []byte(" T sys_"+name+"\n"))
}
// Some syscall names diverge in __NR_* consts and kallsyms.
diff --git a/pkg/ifuzz/encode.go b/pkg/ifuzz/encode.go
index 799def63a..0b3732aa7 100644
--- a/pkg/ifuzz/encode.go
+++ b/pkg/ifuzz/encode.go
@@ -76,7 +76,7 @@ func (insn *Insn) Encode(cfg *Config, r *rand.Rand) []byte {
rex = byte(0x40 | r.Intn(16))
if insn.Rexw == 1 {
rex |= 1 << 3
- } else if insn.Rexw == 1 {
+ } else {
rex &^= 1 << 3
}
rexR = rex&0x4 != 0
diff --git a/pkg/ifuzz/gen/gen.go b/pkg/ifuzz/gen/gen.go
index 47822780c..1ad725e12 100644
--- a/pkg/ifuzz/gen/gen.go
+++ b/pkg/ifuzz/gen/gen.go
@@ -504,7 +504,7 @@ func parseModrm(v string) (int8, error) {
}
vv *= 2
if v[i] == '1' {
- vv += 1
+ vv++
}
}
return vv, nil
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go
index fbce12efa..104be74d2 100644
--- a/pkg/ipc/ipc.go
+++ b/pkg/ipc/ipc.go
@@ -528,6 +528,8 @@ type executeReply struct {
status uint32
}
+// TODO(dvyukov): we currently parse this manually, should cast output to this struct instead.
+/*
type callReply struct {
callIndex uint32
callNum uint32
@@ -539,6 +541,7 @@ type callReply struct {
compsSize uint32
// signal/cover/comps follow
}
+*/
func makeCommand(pid int, bin []string, config *Config, inFile *os.File, outFile *os.File) (*command, error) {
dir, err := ioutil.TempDir("./", "syzkaller-testdir")
@@ -782,7 +785,7 @@ func (c *command) exec(opts *ExecOpts, progData []byte) (output []byte, failed,
hang <- false
}
}()
- exitStatus := 0
+ var exitStatus int
if c.config.Flags&FlagUseForkServer == 0 {
restart = true
c.cmd.Wait()
@@ -849,9 +852,3 @@ func (c *command) exec(opts *ExecOpts, progData []byte) (output []byte, failed,
}
return
}
-
-func serializeUint64(buf []byte, v uint64) {
- for i := 0; i < 8; i++ {
- buf[i] = byte(v >> (8 * uint(i)))
- }
-}
diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go
index 03de4ebf1..88b124a6f 100644
--- a/pkg/ipc/ipc_test.go
+++ b/pkg/ipc/ipc_test.go
@@ -13,7 +13,6 @@ import (
"time"
"github.com/google/syzkaller/pkg/csource"
- "github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/prog"
_ "github.com/google/syzkaller/sys"
)
@@ -25,15 +24,6 @@ func buildExecutor(t *testing.T, target *prog.Target) string {
return buildProgram(t, target, filepath.FromSlash(src))
}
-func buildSource(t *testing.T, target *prog.Target, src []byte) string {
- tmp, err := osutil.WriteTempFile(src)
- if err != nil {
- t.Fatalf("%v", err)
- }
- defer os.Remove(tmp)
- return buildProgram(t, target, tmp)
-}
-
func buildProgram(t *testing.T, target *prog.Target, src string) string {
bin, err := csource.Build(target, "c++", src)
if err != nil {
diff --git a/pkg/kernel/kernel.go b/pkg/kernel/kernel.go
index 2c35bcc40..f1bdcdc83 100644
--- a/pkg/kernel/kernel.go
+++ b/pkg/kernel/kernel.go
@@ -48,10 +48,8 @@ func Build(dir, compiler, config string) error {
}
cmd.Dir = dir
// Build of a large kernel can take a while on a 1 CPU VM.
- if _, err := osutil.Run(3*time.Hour, cmd); err != nil {
- return err
- }
- return nil
+ _, err := osutil.Run(3*time.Hour, cmd)
+ return err
}
// CreateImage creates a disk image that is suitable for syzkaller.
diff --git a/pkg/kernel/kernel_test.go b/pkg/kernel/kernel_test.go
index 750fa50eb..18d7936d0 100644
--- a/pkg/kernel/kernel_test.go
+++ b/pkg/kernel/kernel_test.go
@@ -21,7 +21,7 @@ func TestCompilerIdentity(t *testing.T) {
if len(id) == 0 {
t.Fatalf("identity is empty")
}
- if strings.Index(id, "\n") != -1 {
+ if strings.Contains(id, "\n") {
t.Fatalf("identity contains a new line")
}
// We don't know what's the right answer,
diff --git a/pkg/osutil/fileutil_test.go b/pkg/osutil/fileutil_test.go
index 4db5c0d83..62e07bc8f 100644
--- a/pkg/osutil/fileutil_test.go
+++ b/pkg/osutil/fileutil_test.go
@@ -4,6 +4,7 @@
package osutil
import (
+ "fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -36,29 +37,31 @@ func TestProcessTempDir(t *testing.T) {
}
}
// Now request a bunch of instances concurrently.
- done := make(chan bool)
+ done := make(chan error)
allDirs := make(map[string]bool)
var mu sync.Mutex
for p := 0; p < P; p++ {
go func() {
- defer func() {
- done <- true
- }()
dir, err := ProcessTempDir(tmp)
if err != nil {
- t.Fatalf("failed to create process temp dir")
+ done <- fmt.Errorf("failed to create temp dir: %v", err)
+ return
}
mu.Lock()
present := allDirs[dir]
allDirs[dir] = true
mu.Unlock()
if present {
- t.Fatalf("duplicate dir %v", dir)
+ done <- fmt.Errorf("duplicate dir %v", dir)
+ return
}
+ done <- nil
}()
}
for p := 0; p < P; p++ {
- <-done
+ if err := <-done; err != nil {
+ t.Error(err)
+ }
}
}()
}
diff --git a/pkg/report/linux.go b/pkg/report/linux.go
index 4fbf5ddc3..703b41fb4 100644
--- a/pkg/report/linux.go
+++ b/pkg/report/linux.go
@@ -159,7 +159,7 @@ func (ctx *linux) Parse(output []byte) *Report {
}
}
if ctx.consoleOutputRe.Match(line) &&
- (!ctx.questionableRe.Match(line) || bytes.Index(line, ctx.eoi) != -1) {
+ (!ctx.questionableRe.Match(line) || bytes.Contains(line, ctx.eoi)) {
lineStart := bytes.Index(line, []byte("] ")) + pos + 2
lineEnd := next
if lineEnd != 0 && output[lineEnd-1] == '\r' {
@@ -352,12 +352,8 @@ func symbolizeLine(symbFunc func(bin string, pc uint64) ([]symbolizer.Frame, err
var symbolized []byte
for _, frame := range frames {
file := frame.File
- if strings.HasPrefix(file, strip) {
- file = file[len(strip):]
- }
- if strings.HasPrefix(file, "./") {
- file = file[2:]
- }
+ file = strings.TrimPrefix(file, strip)
+ file = strings.TrimPrefix(file, "./")
info := fmt.Sprintf(" %v:%v", file, frame.Line)
modified := append([]byte{}, line...)
modified = replace(modified, match[7], match[7], []byte(info))
diff --git a/pkg/report/report.go b/pkg/report/report.go
index 89d780b4b..82e68edc4 100644
--- a/pkg/report/report.go
+++ b/pkg/report/report.go
@@ -229,20 +229,6 @@ type stackParams struct {
skipPatterns []string
}
-func startReportPrefix(output []byte, prefixes []string) []byte {
- if len(prefixes) == 0 {
- return output
- }
- for _, prefix := range prefixes {
- re := regexp.MustCompile(prefix + ".*\\n")
- match := re.FindSubmatchIndex(output)
- if match != nil {
- return output[match[0]:]
- }
- }
- return nil
-}
-
func extractStackFrame(params *stackParams, stack *stackFmt, output []byte) string {
skip := append([]string{}, params.skipPatterns...)
skip = append(skip, stack.skip...)
diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go
index fc79f5a8a..ba136743c 100644
--- a/pkg/repro/repro.go
+++ b/pkg/repro/repro.go
@@ -382,7 +382,7 @@ func (ctx *context) extractProgBisect(entries []*prog.LogEntry, baseDuration tim
Duration: dur,
Opts: opts,
}
- ctx.reproLog(3, "bisect: concatenation succeded")
+ ctx.reproLog(3, "bisect: concatenation succeeded")
return res, nil
}
@@ -458,7 +458,7 @@ func (ctx *context) simplifyProg(res *Result) (*Result, error) {
}
if crashed {
res.Opts = opts
- // Simplification successfull, try extracting C repro.
+ // Simplification successful, try extracting C repro.
res, err := ctx.extractC(res)
if err != nil {
return nil, err
@@ -681,7 +681,7 @@ again:
ctx.reproLog(3, "bisect: guilty chunks split: %v, <%v>, %v", logGuilty(guilty1), len(chunk), logGuilty(guilty2))
chunk1 := chunk[0 : len(chunk)/2]
- chunk2 := chunk[len(chunk)/2 : len(chunk)]
+ chunk2 := chunk[len(chunk)/2:]
ctx.reproLog(3, "bisect: chunk split: <%v> => <%v>, <%v>", len(chunk), len(chunk1), len(chunk2))
ctx.reproLog(3, "bisect: triggering crash without chunk #1")
diff --git a/pkg/repro/repro_test.go b/pkg/repro/repro_test.go
index e56e176aa..2cb646c0c 100644
--- a/pkg/repro/repro_test.go
+++ b/pkg/repro/repro_test.go
@@ -35,7 +35,7 @@ func TestBisect(t *testing.T) {
var prog prog.LogEntry
if rd.Intn(30) == 0 {
prog.Proc = 42
- numGuilty += 1
+ numGuilty++
}
progs = append(progs, &prog)
}
@@ -43,13 +43,13 @@ func TestBisect(t *testing.T) {
var prog prog.LogEntry
prog.Proc = 42
progs = append(progs, &prog)
- numGuilty += 1
+ numGuilty++
}
progs, _ = ctx.bisectProgs(progs, func(p []*prog.LogEntry) (bool, error) {
guilty := 0
for _, prog := range p {
if prog.Proc == 42 {
- guilty += 1
+ guilty++
}
}
return guilty == numGuilty, nil
diff --git a/pkg/rpctype/rpc.go b/pkg/rpctype/rpc.go
index 8400b0e95..18d2a04f5 100644
--- a/pkg/rpctype/rpc.go
+++ b/pkg/rpctype/rpc.go
@@ -12,26 +12,26 @@ import (
. "github.com/google/syzkaller/pkg/log"
)
-type RpcServer struct {
+type RPCServer struct {
ln net.Listener
s *rpc.Server
}
-func NewRpcServer(addr string, receiver interface{}) (*RpcServer, error) {
+func NewRPCServer(addr string, receiver interface{}) (*RPCServer, error) {
ln, err := net.Listen("tcp", addr)
if err != nil {
return nil, fmt.Errorf("failed to listen on %v: %v", addr, err)
}
s := rpc.NewServer()
s.Register(receiver)
- serv := &RpcServer{
+ serv := &RPCServer{
ln: ln,
s: s,
}
return serv, nil
}
-func (serv *RpcServer) Serve() {
+func (serv *RPCServer) Serve() {
for {
conn, err := serv.ln.Accept()
if err != nil {
@@ -44,42 +44,42 @@ func (serv *RpcServer) Serve() {
}
}
-func (serv *RpcServer) Addr() net.Addr {
+func (serv *RPCServer) Addr() net.Addr {
return serv.ln.Addr()
}
-type RpcClient struct {
+type RPCClient struct {
conn net.Conn
c *rpc.Client
}
-func NewRpcClient(addr string) (*RpcClient, error) {
+func NewRPCClient(addr string) (*RPCClient, error) {
conn, err := net.DialTimeout("tcp", addr, 60*time.Second)
if err != nil {
return nil, err
}
conn.(*net.TCPConn).SetKeepAlive(true)
conn.(*net.TCPConn).SetKeepAlivePeriod(time.Minute)
- cli := &RpcClient{
+ cli := &RPCClient{
conn: conn,
c: rpc.NewClient(conn),
}
return cli, nil
}
-func (cli *RpcClient) Call(method string, args, reply interface{}) error {
+func (cli *RPCClient) Call(method string, args, reply interface{}) error {
cli.conn.SetDeadline(time.Now().Add(5 * 60 * time.Second))
err := cli.c.Call(method, args, reply)
cli.conn.SetDeadline(time.Time{})
return err
}
-func (cli *RpcClient) Close() {
+func (cli *RPCClient) Close() {
cli.c.Close()
}
-func RpcCall(addr, method string, args, reply interface{}) error {
- c, err := NewRpcClient(addr)
+func RPCCall(addr, method string, args, reply interface{}) error {
+ c, err := NewRPCClient(addr)
if err != nil {
return err
}
diff --git a/pkg/rpctype/rpctype.go b/pkg/rpctype/rpctype.go
index d7fee32da..078d44a7a 100644
--- a/pkg/rpctype/rpctype.go
+++ b/pkg/rpctype/rpctype.go
@@ -9,14 +9,14 @@ import (
"github.com/google/syzkaller/pkg/signal"
)
-type RpcInput struct {
+type RPCInput struct {
Call string
Prog []byte
Signal signal.Serial
Cover []uint32
}
-type RpcCandidate struct {
+type RPCCandidate struct {
Prog []byte
Minimized bool
Smashed bool
@@ -28,9 +28,9 @@ type ConnectArgs struct {
type ConnectRes struct {
Prios [][]float32
- Inputs []RpcInput
+ Inputs []RPCInput
MaxSignal signal.Serial
- Candidates []RpcCandidate
+ Candidates []RPCCandidate
EnabledCalls string
NeedCheck bool
}
@@ -52,7 +52,7 @@ type CheckArgs struct {
type NewInputArgs struct {
Name string
- RpcInput
+ RPCInput
}
type PollArgs struct {
@@ -63,8 +63,8 @@ type PollArgs struct {
}
type PollRes struct {
- Candidates []RpcCandidate
- NewInputs []RpcInput
+ Candidates []RPCCandidate
+ NewInputs []RPCInput
MaxSignal signal.Serial
}
diff --git a/pkg/serializer/serializer.go b/pkg/serializer/serializer.go
index af2708fb3..3054bd3a4 100644
--- a/pkg/serializer/serializer.go
+++ b/pkg/serializer/serializer.go
@@ -129,10 +129,6 @@ func (w *writer) typ(t reflect.Type) {
}
}
-func (w *writer) write(v []byte) {
- w.w.Write(v)
-}
-
func (w *writer) string(v string) {
io.WriteString(w.w, v)
}
diff --git a/pkg/serializer/serializer_test.go b/pkg/serializer/serializer_test.go
index 17cc9550b..7757b345a 100644
--- a/pkg/serializer/serializer_test.go
+++ b/pkg/serializer/serializer_test.go
@@ -39,6 +39,6 @@ type Y struct {
type T int
const (
- T0 T = iota
+ _ T = iota
T1
)
diff --git a/pkg/signal/signal.go b/pkg/signal/signal.go
index 366407d04..e82255537 100644
--- a/pkg/signal/signal.go
+++ b/pkg/signal/signal.go
@@ -114,28 +114,28 @@ func (s Signal) Intersection(s1 Signal) Signal {
return res
}
-func (sp *Signal) Merge(s1 Signal) {
+func (s *Signal) Merge(s1 Signal) {
if s1.Empty() {
return
}
- s := *sp
- if s == nil {
- s = make(Signal, len(s1))
- *sp = s
+ s0 := *s
+ if s0 == nil {
+ s0 = make(Signal, len(s1))
+ *s = s0
}
for e, p1 := range s1 {
- if p, ok := s[e]; !ok || p < p1 {
- s[e] = p1
+ if p, ok := s0[e]; !ok || p < p1 {
+ s0[e] = p1
}
}
}
-type SignalContext struct {
+type Context struct {
Signal Signal
Context interface{}
}
-func Minimize(corpus []SignalContext) []interface{} {
+func Minimize(corpus []Context) []interface{} {
sort.Slice(corpus, func(i, j int) bool {
return corpus[i].Signal.Len() > corpus[j].Signal.Len()
})
diff --git a/pkg/symbolizer/nm.go b/pkg/symbolizer/nm.go
index 72e5db792..01d23ab94 100644
--- a/pkg/symbolizer/nm.go
+++ b/pkg/symbolizer/nm.go
@@ -34,7 +34,7 @@ func ReadSymbols(bin string) (map[string][]Symbol, error) {
for s.Scan() {
// A line looks as: "ffffffff8104db90 0000000000000059 t snb_uncore_msr_enable_box"
ln := s.Bytes()
- if bytes.Index(ln, text[0]) == -1 && bytes.Index(ln, text[1]) == -1 {
+ if !bytes.Contains(ln, text[0]) && !bytes.Contains(ln, text[1]) {
continue
}
sp1 := bytes.IndexByte(ln, ' ')
diff --git a/pkg/symbolizer/symbolizer_test.go b/pkg/symbolizer/symbolizer_test.go
index bb902b290..30a8413f2 100644
--- a/pkg/symbolizer/symbolizer_test.go
+++ b/pkg/symbolizer/symbolizer_test.go
@@ -5,6 +5,7 @@ package symbolizer
import (
"bufio"
+ "fmt"
"os"
"reflect"
"strconv"
@@ -114,7 +115,7 @@ func TestParse(t *testing.T) {
t.Fatal(err)
}
defer outputr.Close()
- done := make(chan bool)
+ done := make(chan error)
go func() {
s := bufio.NewScanner(inputr)
loop:
@@ -122,7 +123,8 @@ func TestParse(t *testing.T) {
pc, err := strconv.ParseUint(s.Text(), 0, 64)
if err != nil {
outputw.Close()
- t.Fatalf("got unexpected pc: %v", s.Text())
+ done <- fmt.Errorf("got unexpected pc: %v", s.Text())
+ return
}
for _, addr := range addresses {
if pc == addr.pc {
@@ -131,7 +133,8 @@ func TestParse(t *testing.T) {
}
}
outputw.Close()
- t.Fatalf("got unexpected pc: 0x%x", pc)
+ done <- fmt.Errorf("got unexpected pc: 0x%x", pc)
+ return
}
outputw.Write([]byte("DONE\n"))
outputw.Close()
@@ -139,7 +142,9 @@ func TestParse(t *testing.T) {
}()
defer func() {
inputw.Close()
- <-done
+ if err := <-done; err != nil {
+ t.Fatal(err)
+ }
}()
// First, symbolize all PCs one-by-one.
diff --git a/prog/any.go b/prog/any.go
index 76e9723b5..d20e56129 100644
--- a/prog/any.go
+++ b/prog/any.go
@@ -5,13 +5,13 @@ import (
)
type anyTypes struct {
- anyUnion *UnionType
- anyArray *ArrayType
- anyBlob *BufferType
- anyPtrPtr *PtrType
- anyPtr64 *PtrType
- anyRes32 *ResourceType
- anyRes64 *ResourceType
+ union *UnionType
+ array *ArrayType
+ blob *BufferType
+ ptrPtr *PtrType
+ ptr64 *PtrType
+ res32 *ResourceType
+ res64 *ResourceType
}
// This generates type descriptions for:
@@ -26,36 +26,36 @@ type anyTypes struct {
// res64 ANYRES64
// ] [varlen]
func initAnyTypes(target *Target) {
- target.anyUnion = &UnionType{
+ target.any.union = &UnionType{
FldName: "ANYUNION",
}
- target.anyArray = &ArrayType{
+ target.any.array = &ArrayType{
TypeCommon: TypeCommon{
TypeName: "ANYARRAY",
FldName: "ANYARRAY",
IsVarlen: true,
},
- Type: target.anyUnion,
+ Type: target.any.union,
}
- target.anyPtrPtr = &PtrType{
+ target.any.ptrPtr = &PtrType{
TypeCommon: TypeCommon{
TypeName: "ptr",
FldName: "ANYPTR",
TypeSize: target.PtrSize,
IsOptional: true,
},
- Type: target.anyArray,
+ Type: target.any.array,
}
- target.anyPtr64 = &PtrType{
+ target.any.ptr64 = &PtrType{
TypeCommon: TypeCommon{
TypeName: "ptr64",
FldName: "ANYPTR64",
TypeSize: 8,
IsOptional: true,
},
- Type: target.anyArray,
+ Type: target.any.array,
}
- target.anyBlob = &BufferType{
+ target.any.blob = &BufferType{
TypeCommon: TypeCommon{
TypeName: "ANYBLOB",
FldName: "ANYBLOB",
@@ -86,9 +86,9 @@ func initAnyTypes(target *Target) {
},
}
}
- target.anyRes32 = createResource("ANYRES32", "int32", 4)
- target.anyRes64 = createResource("ANYRES64", "int64", 8)
- target.anyUnion.StructDesc = &StructDesc{
+ target.any.res32 = createResource("ANYRES32", "int32", 4)
+ target.any.res64 = createResource("ANYRES64", "int64", 8)
+ target.any.union.StructDesc = &StructDesc{
TypeCommon: TypeCommon{
TypeName: "ANYUNION",
FldName: "ANYUNION",
@@ -96,11 +96,11 @@ func initAnyTypes(target *Target) {
ArgDir: DirIn,
},
Fields: []Type{
- target.anyBlob,
- target.anyPtrPtr,
- target.anyPtr64,
- target.anyRes32,
- target.anyRes64,
+ target.any.blob,
+ target.any.ptrPtr,
+ target.any.ptr64,
+ target.any.res32,
+ target.any.res64,
},
}
}
@@ -110,9 +110,9 @@ func (target *Target) makeAnyPtrType(size uint64, field string) *PtrType {
// and field names are used as len target.
var typ PtrType
if size == target.PtrSize {
- typ = *target.anyPtrPtr
+ typ = *target.any.ptrPtr
} else if size == 8 {
- typ = *target.anyPtr64
+ typ = *target.any.ptr64
} else {
panic(fmt.Sprintf("bad pointer size %v", size))
}
@@ -125,7 +125,7 @@ func (target *Target) makeAnyPtrType(size uint64, field string) *PtrType {
func (target *Target) isAnyPtr(typ Type) bool {
ptr, ok := typ.(*PtrType)
- return ok && ptr.Type == target.anyArray
+ return ok && ptr.Type == target.any.array
}
func (p *Prog) complexPtrs() (res []*PointerArg) {
@@ -228,17 +228,17 @@ func (target *Target) squashPtrImpl(a Arg, elems *[]Arg) {
case *ResultArg:
switch arg.Size() {
case 4:
- arg.typ = target.anyRes32
+ arg.typ = target.any.res32
case 8:
- arg.typ = target.anyRes64
+ arg.typ = target.any.res64
default:
panic("bad size")
}
- *elems = append(*elems, MakeUnionArg(target.anyUnion, arg))
+ *elems = append(*elems, MakeUnionArg(target.any.union, arg))
case *PointerArg:
if arg.Res != nil {
target.squashPtr(arg, false)
- *elems = append(*elems, MakeUnionArg(target.anyUnion, arg))
+ *elems = append(*elems, MakeUnionArg(target.any.union, arg))
} else {
elem := target.ensureDataElem(elems)
addr := target.PhysicalAddr(arg)
@@ -314,14 +314,14 @@ func (target *Target) squashConst(arg *ConstArg) uint64 {
func (target *Target) ensureDataElem(elems *[]Arg) *DataArg {
if len(*elems) == 0 {
- res := MakeDataArg(target.anyBlob, nil)
- *elems = append(*elems, MakeUnionArg(target.anyUnion, res))
+ res := MakeDataArg(target.any.blob, nil)
+ *elems = append(*elems, MakeUnionArg(target.any.union, res))
return res
}
res, ok := (*elems)[len(*elems)-1].(*UnionArg).Option.(*DataArg)
if !ok {
- res = MakeDataArg(target.anyBlob, nil)
- *elems = append(*elems, MakeUnionArg(target.anyUnion, res))
+ res = MakeDataArg(target.any.blob, nil)
+ *elems = append(*elems, MakeUnionArg(target.any.union, res))
}
return res
}
diff --git a/prog/encoding.go b/prog/encoding.go
index 26ca80285..b409b7b81 100644
--- a/prog/encoding.go
+++ b/prog/encoding.go
@@ -317,7 +317,7 @@ top:
p.Parse('Y')
p.Parse('=')
typ = target.makeAnyPtrType(typ.Size(), typ.FieldName())
- typ1 = target.anyArray
+ typ1 = target.any.array
}
inner, err = target.parseArg(typ1, p, vars)
if err != nil {
@@ -797,8 +797,6 @@ func (p *parser) Ident() string {
p.failf("failed to parse identifier at pos %v", i)
return ""
}
- if ch := p.s[i]; ch >= '0' && ch <= '9' {
- }
s := p.s[i:p.i]
p.SkipWs()
return s
diff --git a/prog/minimization.go b/prog/minimization.go
index ea5072c97..8f2cbae61 100644
--- a/prog/minimization.go
+++ b/prog/minimization.go
@@ -9,7 +9,7 @@ import (
// Minimize minimizes program p into an equivalent program using the equivalence
// predicate pred. It iteratively generates simpler programs and asks pred
-// whether it is equal to the orginal program or not. If it is equivalent then
+// whether it is equal to the original program or not. If it is equivalent then
// the simplification attempt is committed and the process continues.
func Minimize(p0 *Prog, callIndex0 int, crash bool, pred0 func(*Prog, int) bool) (*Prog, int) {
pred := pred0
@@ -119,9 +119,8 @@ func Minimize(p0 *Prog, callIndex0 int, crash bool, pred0 func(*Prog, int) bool)
if pred(p, callIndex0) {
p0 = p
return true
- } else {
- a.Val = v0
}
+ a.Val = v0
case *ResourceType:
if crash {
return false
@@ -140,10 +139,9 @@ func Minimize(p0 *Prog, callIndex0 int, crash bool, pred0 func(*Prog, int) bool)
if pred(p, callIndex0) {
p0 = p
return true
- } else {
- a.Res = r0
- a.Val = 0
}
+ a.Res = r0
+ a.Val = 0
case *BufferType:
// TODO: try to set individual bytes to 0
if triedPaths[path] {
diff --git a/prog/prog.go b/prog/prog.go
index 769161f7a..fe9293433 100644
--- a/prog/prog.go
+++ b/prog/prog.go
@@ -250,9 +250,8 @@ func MakeUnionArg(t Type, opt Arg) *UnionArg {
func (arg *UnionArg) Size() uint64 {
if !arg.Type().Varlen() {
return arg.Type().Size()
- } else {
- return arg.Option.Size()
}
+ return arg.Option.Size()
}
// Used for ResourceType.
@@ -319,9 +318,8 @@ func InnerArg(arg Arg) Arg {
panic(fmt.Sprintf("non-optional pointer is nil\narg: %+v\ntype: %+v", a, t))
}
return nil
- } else {
- return InnerArg(a.Res)
}
+ return InnerArg(a.Res)
}
return nil // *ConstArg.
}
@@ -504,44 +502,6 @@ func replaceResultArg(arg, arg1 *ResultArg) {
}
}
-// replaceArgCheck checks that c and arg belog to p.
-func (p *Prog) replaceArgCheck(c *Call, arg, arg1 Arg, calls []*Call) {
- foundCall, foundArg := false, false
- for _, c0 := range p.Calls {
- if c0 == c {
- if foundCall {
- panic("duplicate call")
- }
- foundCall = true
- }
- for _, newC := range calls {
- if c0 == newC {
- panic("call is already in prog")
- }
- }
- ForeachArg(c0, func(arg0 Arg, _ *ArgCtx) {
- if arg0 == arg {
- if c0 != c {
- panic("wrong call")
- }
- if foundArg {
- panic("duplicate arg")
- }
- foundArg = true
- }
- if arg0 == arg1 {
- panic("arg is already in prog")
- }
- })
- }
- if !foundCall {
- panic("call is not in prog")
- }
- if !foundArg {
- panic("arg is not in prog")
- }
-}
-
// removeArg removes all references to/from arg0 from a program.
func removeArg(arg0 Arg) {
ForeachSubArg(arg0, func(arg Arg, ctx *ArgCtx) {
diff --git a/prog/rand.go b/prog/rand.go
index d8ba0f33d..ec5e378ca 100644
--- a/prog/rand.go
+++ b/prog/rand.go
@@ -488,9 +488,9 @@ func (r *randGen) generateArgImpl(s *state, typ Type, ignoreSpecial bool) (arg A
switch pt.Type.(type) {
case *StructType, *ArrayType, *UnionType:
name := pt.Type.Name()
- r.recDepth[name] += 1
+ r.recDepth[name]++
defer func() {
- r.recDepth[name] -= 1
+ r.recDepth[name]--
if r.recDepth[name] == 0 {
delete(r.recDepth, name)
}
diff --git a/prog/resources.go b/prog/resources.go
index 6ae33c83f..299e8571c 100644
--- a/prog/resources.go
+++ b/prog/resources.go
@@ -33,7 +33,7 @@ func (target *Target) calcResourceCtors(kind []string, precise bool) []*Syscall
// isCompatibleResource returns true if resource of kind src can be passed as an argument of kind dst.
func (target *Target) isCompatibleResource(dst, src string) bool {
- if dst == target.anyRes32.TypeName || dst == target.anyRes64.TypeName {
+ if dst == target.any.res32.TypeName || dst == target.any.res64.TypeName {
return true
}
dstRes := target.resourceMap[dst]
diff --git a/prog/size.go b/prog/size.go
index ab8d97717..c16e7f647 100644
--- a/prog/size.go
+++ b/prog/size.go
@@ -26,9 +26,8 @@ func (target *Target) generateSize(arg Arg, lenType *LenType) uint64 {
a := arg.(*GroupArg)
if lenType.BitSize != 0 {
return a.Size() * 8 / bitSize
- } else {
- return uint64(len(a.Inner))
}
+ return uint64(len(a.Inner))
default:
return arg.Size() * 8 / bitSize
}
diff --git a/prog/size_test.go b/prog/size_test.go
index d9ede1739..038c05f3f 100644
--- a/prog/size_test.go
+++ b/prog/size_test.go
@@ -21,7 +21,7 @@ func TestAssignSizeRandom(t *testing.T) {
t.Fatalf("different lens assigned, initial:\n%s\nnew:\n%s\n", data0, data1)
}
p.Mutate(rs, 10, nil, nil)
- data0 = p.Serialize()
+ p.Serialize()
for _, call := range p.Calls {
target.assignSizesCall(call)
}
diff --git a/prog/target.go b/prog/target.go
index 870b924fc..80a2665ae 100644
--- a/prog/target.go
+++ b/prog/target.go
@@ -52,7 +52,7 @@ type Target struct {
resourceMap map[string]*ResourceDesc
// Maps resource name to a list of calls that can create the resource.
resourceCtors map[string][]*Syscall
- anyTypes
+ any anyTypes
}
var targets = make(map[string]*Target)
diff --git a/prog/validation.go b/prog/validation.go
index 8f01d6df5..1c0761d68 100644
--- a/prog/validation.go
+++ b/prog/validation.go
@@ -256,8 +256,8 @@ func (p *Prog) validateCall(ctx *validCtx, c *Call) error {
break
}
if !ctx.args[a.Res] {
- return fmt.Errorf("syscall %v: result arg '%v' references out-of-tree result: %p%+v -> %p%+v",
- c.Meta.Name, a.Type().Name(), arg, arg, a.Res, a.Res)
+ return fmt.Errorf("syscall %v: result arg %v references out-of-tree result: %#v -> %#v",
+ c.Meta.Name, a.Type().Name(), arg, a.Res)
}
if !(*a.Res.(ArgUsed).Used())[arg] {
return fmt.Errorf("syscall %v: result arg '%v' has broken link (%+v)",
diff --git a/sys/freebsd/init.go b/sys/freebsd/init.go
index ed02e712e..65da1d911 100644
--- a/sys/freebsd/init.go
+++ b/sys/freebsd/init.go
@@ -31,8 +31,7 @@ const (
)
type arch struct {
- mmapSyscall *prog.Syscall
- clockGettimeSyscall *prog.Syscall
+ mmapSyscall *prog.Syscall
PROT_READ uint64
PROT_WRITE uint64
diff --git a/sys/linux/386.go b/sys/linux/386.go
index 25ebbe735..516320890 100644
--- a/sys/linux/386.go
+++ b/sys/linux/386.go
@@ -2852,7 +2852,7 @@ var structDescs_386 = []*KeyedStruct{
&CsumType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "csum", FldName: "csum", TypeSize: 2}, BigEndian: true}, Buf: "parent"},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pointer", TypeSize: 1}}},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "length", TypeSize: 1}}},
- &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unsed", TypeSize: 2}}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unused", TypeSize: 2}}},
&StructType{Key: StructKey{Name: "icmp_ipv4_header"}, FldName: "iph"},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "data", IsVarlen: true}, Kind: 1, RangeEnd: 8},
}}},
@@ -25573,4 +25573,4 @@ var consts_386 = []ConstValue{
{Name: "bpf_insn_load_imm_dw", Value: 24},
}
-const revision_386 = "a4d19f3d89c6652e30a30a8f16bb22eedea9571e"
+const revision_386 = "8a515582f716e47c7187d6acd9ef3c3e8b30a7f9"
diff --git a/sys/linux/amd64.go b/sys/linux/amd64.go
index f3801be2a..42d311588 100644
--- a/sys/linux/amd64.go
+++ b/sys/linux/amd64.go
@@ -2938,7 +2938,7 @@ var structDescs_amd64 = []*KeyedStruct{
&CsumType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "csum", FldName: "csum", TypeSize: 2}, BigEndian: true}, Buf: "parent"},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pointer", TypeSize: 1}}},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "length", TypeSize: 1}}},
- &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unsed", TypeSize: 2}}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unused", TypeSize: 2}}},
&StructType{Key: StructKey{Name: "icmp_ipv4_header"}, FldName: "iph"},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "data", IsVarlen: true}, Kind: 1, RangeEnd: 8},
}}},
@@ -26189,4 +26189,4 @@ var consts_amd64 = []ConstValue{
{Name: "bpf_insn_load_imm_dw", Value: 24},
}
-const revision_amd64 = "0a160a2283a1e3ba08b37705ee1dbb6670b86af6"
+const revision_amd64 = "d701f2a2142a12c08b17afbc15110c24f09bf0da"
diff --git a/sys/linux/arm.go b/sys/linux/arm.go
index 6dcfebac7..31fb52c01 100644
--- a/sys/linux/arm.go
+++ b/sys/linux/arm.go
@@ -2837,7 +2837,7 @@ var structDescs_arm = []*KeyedStruct{
&CsumType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "csum", FldName: "csum", TypeSize: 2}, BigEndian: true}, Buf: "parent"},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pointer", TypeSize: 1}}},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "length", TypeSize: 1}}},
- &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unsed", TypeSize: 2}}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unused", TypeSize: 2}}},
&StructType{Key: StructKey{Name: "icmp_ipv4_header"}, FldName: "iph"},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "data", IsVarlen: true}, Kind: 1, RangeEnd: 8},
}}},
@@ -25294,4 +25294,4 @@ var consts_arm = []ConstValue{
{Name: "bpf_insn_load_imm_dw", Value: 24},
}
-const revision_arm = "8f884a3256f4d0f2a84807391e479e7713ba6fac"
+const revision_arm = "28772c035814f22d291032fc0d3a14c1ea6d4d34"
diff --git a/sys/linux/arm64.go b/sys/linux/arm64.go
index 94faf34f8..3ad3b1078 100644
--- a/sys/linux/arm64.go
+++ b/sys/linux/arm64.go
@@ -2938,7 +2938,7 @@ var structDescs_arm64 = []*KeyedStruct{
&CsumType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "csum", FldName: "csum", TypeSize: 2}, BigEndian: true}, Buf: "parent"},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pointer", TypeSize: 1}}},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "length", TypeSize: 1}}},
- &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unsed", TypeSize: 2}}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unused", TypeSize: 2}}},
&StructType{Key: StructKey{Name: "icmp_ipv4_header"}, FldName: "iph"},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "data", IsVarlen: true}, Kind: 1, RangeEnd: 8},
}}},
@@ -25571,4 +25571,4 @@ var consts_arm64 = []ConstValue{
{Name: "bpf_insn_load_imm_dw", Value: 24},
}
-const revision_arm64 = "a227f9eaa7342c1fc70e2518d7d2637f13f704b8"
+const revision_arm64 = "32119668c79bbf78e86ee2739b37d2d06b458ff6"
diff --git a/sys/linux/init_alg_test.go b/sys/linux/init_alg_test.go
index b3622a6c9..d1c049d12 100644
--- a/sys/linux/init_alg_test.go
+++ b/sys/linux/init_alg_test.go
@@ -190,6 +190,8 @@ func testAlg(t *testing.T, typ, name string) (ok, skip bool) {
const AF_ALG = 0x26
addr := &sockaddrAlg{
family: AF_ALG,
+ feat: 0,
+ mask: 0,
}
if len(typ) >= int(unsafe.Sizeof(addr.typ)) ||
len(name) >= int(unsafe.Sizeof(addr.name)) {
diff --git a/sys/linux/init_iptables.go b/sys/linux/init_iptables.go
index 86001b4c3..231bcfb77 100644
--- a/sys/linux/init_iptables.go
+++ b/sys/linux/init_iptables.go
@@ -64,9 +64,8 @@ func (arch *arch) generateNetfilterTable(g *prog.Gen, typ prog.Type, old prog.Ar
// Assign the underflow entry once in a while.
// We have it in underflow hooks, so no point in using it frequently.
return pos
- } else {
- return offsets[g.Rand().Intn(len(offsets))]
}
+ return offsets[g.Rand().Intn(len(offsets))]
}
// Assign offsets to used hooks.
for hook := hookStart; hook < hookStart+hookCount; hook++ {
diff --git a/sys/linux/ppc64le.go b/sys/linux/ppc64le.go
index 2211ecd50..2c893c445 100644
--- a/sys/linux/ppc64le.go
+++ b/sys/linux/ppc64le.go
@@ -2932,7 +2932,7 @@ var structDescs_ppc64le = []*KeyedStruct{
&CsumType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "csum", FldName: "csum", TypeSize: 2}, BigEndian: true}, Buf: "parent"},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pointer", TypeSize: 1}}},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "length", TypeSize: 1}}},
- &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unsed", TypeSize: 2}}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "unused", TypeSize: 2}}},
&StructType{Key: StructKey{Name: "icmp_ipv4_header"}, FldName: "iph"},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "data", IsVarlen: true}, Kind: 1, RangeEnd: 8},
}}},
@@ -25333,4 +25333,4 @@ var consts_ppc64le = []ConstValue{
{Name: "bpf_insn_load_imm_dw", Value: 24},
}
-const revision_ppc64le = "0a6ad6424c9561f4fddaeab2c50b92213fd76f79"
+const revision_ppc64le = "83087ab2eb13cc0b1b58ad876c88d5c0920863c7"
diff --git a/sys/linux/vnet.txt b/sys/linux/vnet.txt
index 1b57b202f..b046c9733 100644
--- a/sys/linux/vnet.txt
+++ b/sys/linux/vnet.txt
@@ -1053,7 +1053,7 @@ icmp_parameter_prob_packet {
csum csum[parent, inet, int16be]
pointer int8
length int8
- unsed const[0, int16]
+ unused const[0, int16]
iph icmp_ipv4_header
data array[int8, 0:8]
} [packed]
diff --git a/sys/netbsd/init.go b/sys/netbsd/init.go
index 3af3619b6..2175e29af 100644
--- a/sys/netbsd/init.go
+++ b/sys/netbsd/init.go
@@ -26,8 +26,7 @@ const (
)
type arch struct {
- mmapSyscall *prog.Syscall
- clockGettimeSyscall *prog.Syscall
+ mmapSyscall *prog.Syscall
PROT_READ uint64
PROT_WRITE uint64
diff --git a/sys/sys.go b/sys/sys.go
index 5989d1fec..e67093e16 100644
--- a/sys/sys.go
+++ b/sys/sys.go
@@ -4,6 +4,7 @@
package sys
import (
+ // Import all targets, so that users only need to import sys.
_ "github.com/google/syzkaller/sys/akaros"
_ "github.com/google/syzkaller/sys/freebsd"
_ "github.com/google/syzkaller/sys/fuchsia"
diff --git a/sys/syz-extract/linux.go b/sys/syz-extract/linux.go
index 99cfb44e2..5c428461c 100644
--- a/sys/syz-extract/linux.go
+++ b/sys/syz-extract/linux.go
@@ -31,7 +31,7 @@ func (*linux) prepare(sourcedir string, build bool, arches []string) error {
out, err := osutil.RunCmd(time.Hour, sourcedir, "make", "mrproper",
"-j", fmt.Sprint(runtime.NumCPU()))
if err != nil {
- return fmt.Errorf("make mrproper failed: %v\n%s\n", err, out)
+ return fmt.Errorf("make mrproper failed: %v\n%s", err, out)
}
}
} else {
@@ -58,21 +58,21 @@ func (*linux) prepareArch(arch *Arch) error {
}
out, err := osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "defconfig")...)
if err != nil {
- return fmt.Errorf("make defconfig failed: %v\n%s\n", err, out)
+ return fmt.Errorf("make defconfig failed: %v\n%s", err, out)
}
// Without CONFIG_NETFILTER kernel does not build.
out, err = osutil.RunCmd(time.Minute, buildDir, "sed", "-i",
"s@# CONFIG_NETFILTER is not set@CONFIG_NETFILTER=y@g", ".config")
if err != nil {
- return fmt.Errorf("sed .config failed: %v\n%s\n", err, out)
+ return fmt.Errorf("sed .config failed: %v\n%s", err, out)
}
out, err = osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "olddefconfig")...)
if err != nil {
- return fmt.Errorf("make olddefconfig failed: %v\n%s\n", err, out)
+ return fmt.Errorf("make olddefconfig failed: %v\n%s", err, out)
}
out, err = osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "init/main.o")...)
if err != nil {
- return fmt.Errorf("make failed: %v\n%s\n", err, out)
+ return fmt.Errorf("make failed: %v\n%s", err, out)
}
return nil
}
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go
index d91970f59..826a442a0 100644
--- a/sys/syz-sysgen/sysgen.go
+++ b/sys/syz-sysgen/sysgen.go
@@ -28,7 +28,6 @@ import (
)
var (
- flagV = flag.Int("v", 0, "verbosity")
flagMemProfile = flag.String("memprofile", "", "write a memory profile to the file")
)
@@ -245,12 +244,6 @@ func failf(msg string, args ...interface{}) {
os.Exit(1)
}
-func logf(v int, msg string, args ...interface{}) {
- if *flagV >= v {
- fmt.Fprintf(os.Stderr, msg+"\n", args...)
- }
-}
-
var archTempl = template.Must(template.New("").Parse(`
#if {{range $cdef := $.CARCH}}defined({{$cdef}}) || {{end}}0
#define GOARCH "{{.GOARCH}}"
diff --git a/syz-ci/jobs.go b/syz-ci/jobs.go
index af248b52c..68d69010f 100644
--- a/syz-ci/jobs.go
+++ b/syz-ci/jobs.go
@@ -263,7 +263,7 @@ func (jp *JobProcessor) buildImage(job *Job) error {
mgrcfg.Kernel_Src = kernelDir
mgrcfg.Syzkaller = syzkallerDir
mgrcfg.Image = image
- mgrcfg.Sshkey = key
+ mgrcfg.SSHKey = key
// Reload config to fill derived fields (ugly hack).
cfgdata, err := config.SaveData(mgrcfg)
diff --git a/syz-ci/manager.go b/syz-ci/manager.go
index 3ba8d578d..f916fa5f7 100644
--- a/syz-ci/manager.go
+++ b/syz-ci/manager.go
@@ -420,7 +420,7 @@ func (mgr *Manager) createTestConfig(imageDir string, info *BuildInfo) (*mgrconf
mgrcfg.Workdir = filepath.Join(imageDir, "workdir")
mgrcfg.Vmlinux = filepath.Join(imageDir, "obj", "vmlinux")
mgrcfg.Image = filepath.Join(imageDir, "image")
- mgrcfg.Sshkey = filepath.Join(imageDir, "key")
+ mgrcfg.SSHKey = filepath.Join(imageDir, "key")
mgrcfg.Kernel_Src = mgr.kernelDir
mgrcfg.Syzkaller = filepath.FromSlash("syzkaller/current")
cfgdata, err := config.SaveData(mgrcfg)
@@ -457,7 +457,7 @@ func (mgr *Manager) writeConfig(buildTag string) (string, error) {
mgrcfg.Kernel_Src = mgr.kernelDir
mgrcfg.Syzkaller = filepath.FromSlash("syzkaller/current")
mgrcfg.Image = filepath.Join(mgr.currentDir, "image")
- mgrcfg.Sshkey = filepath.Join(mgr.currentDir, "key")
+ mgrcfg.SSHKey = filepath.Join(mgr.currentDir, "key")
configFile := filepath.Join(mgr.currentDir, "manager.cfg")
if err := config.SaveFile(configFile, mgrcfg); err != nil {
diff --git a/syz-ci/syz-ci.go b/syz-ci/syz-ci.go
index c5efc7bbc..7a404279b 100644
--- a/syz-ci/syz-ci.go
+++ b/syz-ci/syz-ci.go
@@ -69,7 +69,7 @@ var flagConfig = flag.String("config", "", "config file")
type Config struct {
Name string
- Http string
+ HTTP string
Dashboard_Addr string // Optional.
Dashboard_Client string // Optional.
Dashboard_Key string // Optional.
@@ -171,7 +171,7 @@ func loadConfig(filename string) (*Config, error) {
if cfg.Name == "" {
return nil, fmt.Errorf("param 'name' is empty")
}
- if cfg.Http == "" {
+ if cfg.HTTP == "" {
return nil, fmt.Errorf("param 'http' is empty")
}
if len(cfg.Managers) == 0 {
diff --git a/syz-ci/testing.go b/syz-ci/testing.go
index adf223f04..f1040155f 100644
--- a/syz-ci/testing.go
+++ b/syz-ci/testing.go
@@ -69,7 +69,6 @@ func testInstance(inst *vm.Instance, reporter report.Reporter, mgrcfg *mgrconfig
conn.Close()
atomic.StoreUint32(&gotConn, 1)
}
- return
}()
fwdAddr, err := inst.Forward(ln.Addr().(*net.TCPAddr).Port)
if err != nil {
diff --git a/syz-fuzzer/fuzzer.go b/syz-fuzzer/fuzzer.go
index 5c1b9c475..0f5b9faf8 100644
--- a/syz-fuzzer/fuzzer.go
+++ b/syz-fuzzer/fuzzer.go
@@ -40,7 +40,7 @@ type Fuzzer struct {
needPoll chan struct{}
choiceTable *prog.ChoiceTable
stats [StatCount]uint64
- manager *RpcClient
+ manager *RPCClient
target *prog.Target
faultInjectionEnabled bool
@@ -167,7 +167,7 @@ func main() {
Logf(0, "dialing manager at %v", *flagManager)
a := &ConnectArgs{*flagName}
r := &ConnectRes{}
- if err := RpcCall(*flagManager, "Manager.Connect", a, r); err != nil {
+ if err := RPCCall(*flagManager, "Manager.Connect", a, r); err != nil {
panic(err)
}
calls := buildCallList(target, r.EnabledCalls, sandbox)
@@ -219,7 +219,7 @@ func main() {
for c := range calls {
a.Calls = append(a.Calls, c.Name)
}
- if err := RpcCall(*flagManager, "Manager.Check", a, nil); err != nil {
+ if err := RPCCall(*flagManager, "Manager.Check", a, nil); err != nil {
panic(err)
}
}
@@ -228,7 +228,7 @@ func main() {
// So we do the call on a transient connection, free all memory and reconnect.
// The rest of rpc requests have bounded size.
debug.FreeOSMemory()
- manager, err := NewRpcClient(*flagManager)
+ manager, err := NewRPCClient(*flagManager)
if err != nil {
panic(err)
}
@@ -414,17 +414,17 @@ func buildCallList(target *prog.Target, enabledCalls, sandbox string) map[*prog.
return calls
}
-func (fuzzer *Fuzzer) sendInputToManager(inp RpcInput) {
+func (fuzzer *Fuzzer) sendInputToManager(inp RPCInput) {
a := &NewInputArgs{
Name: fuzzer.name,
- RpcInput: inp,
+ RPCInput: inp,
}
if err := fuzzer.manager.Call("Manager.NewInput", a, nil); err != nil {
panic(err)
}
}
-func (fuzzer *Fuzzer) addInputFromAnotherFuzzer(inp RpcInput) {
+func (fuzzer *Fuzzer) addInputFromAnotherFuzzer(inp RPCInput) {
if !fuzzer.coverageEnabled {
panic("should not be called when coverage is disabled")
}
diff --git a/syz-fuzzer/fuzzer_linux.go b/syz-fuzzer/fuzzer_linux.go
index f0114ef9c..b91b7bac0 100644
--- a/syz-fuzzer/fuzzer_linux.go
+++ b/syz-fuzzer/fuzzer_linux.go
@@ -84,7 +84,7 @@ func kmemleakScan(report bool) {
for kmemleakBuf = kmemleakBuf[:n]; len(kmemleakBuf) != 0; {
end := bytes.Index(kmemleakBuf[1:], []byte("unreferenced object"))
if end != -1 {
- end += 1
+ end++
} else {
end = len(kmemleakBuf)
}
@@ -110,7 +110,7 @@ func kmemleakScan(report bool) {
func kmemleakIgnore(report []byte) bool {
// kmemleak has a bunch of false positives (at least what looks like
- // false positives at first glance). So we are concervative with what we report.
+ // false positives at first glance). So we are conservative with what we report.
// First, we filter out any allocations that don't come from executor processes.
// Second, we ignore a bunch of functions entirely.
// Ideally, someone should debug/fix all these cases and remove ignores.
diff --git a/syz-fuzzer/proc.go b/syz-fuzzer/proc.go
index 104d7b477..6cfd92c71 100644
--- a/syz-fuzzer/proc.go
+++ b/syz-fuzzer/proc.go
@@ -165,7 +165,7 @@ func (proc *Proc) triageInput(item *WorkTriage) {
sig := hash.Hash(data)
Logf(2, "added new input for %v to corpus:\n%s", call.Meta.CallName, data)
- proc.fuzzer.sendInputToManager(RpcInput{
+ proc.fuzzer.sendInputToManager(RPCInput{
Call: call.Meta.CallName,
Prog: data,
Signal: inputSignal.Serialize(),
diff --git a/syz-hub/http.go b/syz-hub/http.go
index aa99760f3..f7a01c91b 100644
--- a/syz-hub/http.go
+++ b/syz-hub/http.go
@@ -14,7 +14,7 @@ import (
. "github.com/google/syzkaller/pkg/log"
)
-func (hub *Hub) initHttp(addr string) {
+func (hub *Hub) initHTTP(addr string) {
http.HandleFunc("/", hub.httpSummary)
ln, err := net.Listen("tcp4", addr)
diff --git a/syz-hub/hub.go b/syz-hub/hub.go
index 11211be57..f8509f3a3 100644
--- a/syz-hub/hub.go
+++ b/syz-hub/hub.go
@@ -20,8 +20,8 @@ var (
)
type Config struct {
- Http string
- Rpc string
+ HTTP string
+ RPC string
Workdir string
Clients []struct {
Name string
@@ -55,9 +55,9 @@ func main() {
hub.keys[mgr.Name] = mgr.Key
}
- hub.initHttp(cfg.Http)
+ hub.initHTTP(cfg.HTTP)
- s, err := NewRpcServer(cfg.Rpc, hub)
+ s, err := NewRPCServer(cfg.RPC, hub)
if err != nil {
Fatalf("failed to create rpc server: %v", err)
}
diff --git a/syz-manager/cover.go b/syz-manager/cover.go
index 182be3030..6ce2ab35c 100644
--- a/syz-manager/cover.go
+++ b/syz-manager/cover.go
@@ -91,12 +91,12 @@ func initAllCover(vmlinux string) {
}()
}
-func generateCoverHtml(w io.Writer, vmlinux string, cov cover.Cover) error {
+func generateCoverHTML(w io.Writer, vmlinux string, cov cover.Cover) error {
if len(cov) == 0 {
return fmt.Errorf("No coverage data available")
}
- base, err := getVmOffset(vmlinux)
+ base, err := getVMOffset(vmlinux)
if err != nil {
return err
}
@@ -109,7 +109,7 @@ func generateCoverHtml(w io.Writer, vmlinux string, cov cover.Cover) error {
return err
}
- coveredFrames, prefix, err := symbolize(vmlinux, pcs)
+ coveredFrames, _, err := symbolize(vmlinux, pcs)
if err != nil {
return err
}
@@ -148,10 +148,7 @@ func generateCoverHtml(w io.Writer, vmlinux string, cov cover.Cover) error {
buf.Write([]byte{'\n'})
}
}
- if len(f) > len(prefix) {
- f = f[len(prefix):]
- }
- f = filepath.Clean(f)
+ f = filepath.Clean(strings.TrimPrefix(f, prefix))
d.Files = append(d.Files, &templateFile{
ID: hash.String([]byte(f)),
Name: f,
@@ -161,10 +158,7 @@ func generateCoverHtml(w io.Writer, vmlinux string, cov cover.Cover) error {
}
sort.Sort(templateFileArray(d.Files))
- if err := coverTemplate.Execute(w, d); err != nil {
- return err
- }
- return nil
+ return coverTemplate.Execute(w, d)
}
func fileSet(covered, uncovered []symbolizer.Frame) map[string][]coverage {
@@ -221,7 +215,7 @@ func parseFile(fn string) ([][]byte, error) {
return lines, nil
}
-func getVmOffset(vmlinux string) (uint32, error) {
+func getVMOffset(vmlinux string) (uint32, error) {
if v, ok := vmOffsets[vmlinux]; ok {
return v, nil
}
@@ -332,7 +326,7 @@ func coveredPCs(bin string) ([]uint64, error) {
ln := s.Bytes()
if pos := bytes.Index(ln, callInsn); pos == -1 {
continue
- } else if bytes.Index(ln[pos:], traceFunc) == -1 {
+ } else if !bytes.Contains(ln[pos:], traceFunc) {
continue
}
colon := bytes.IndexByte(ln, ':')
diff --git a/syz-manager/html.go b/syz-manager/html.go
index de4aeb912..c71034752 100644
--- a/syz-manager/html.go
+++ b/syz-manager/html.go
@@ -27,7 +27,7 @@ import (
const dateFormat = "Jan 02 2006 15:04:05 MST"
-func (mgr *Manager) initHttp() {
+func (mgr *Manager) initHTTP() {
http.HandleFunc("/", mgr.httpSummary)
http.HandleFunc("/corpus", mgr.httpCorpus)
http.HandleFunc("/crash", mgr.httpCrash)
@@ -39,9 +39,9 @@ func (mgr *Manager) initHttp() {
// Browsers like to request this, without special handler this goes to / handler.
http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {})
- ln, err := net.Listen("tcp4", mgr.cfg.Http)
+ ln, err := net.Listen("tcp4", mgr.cfg.HTTP)
if err != nil {
- Fatalf("failed to listen on %v: %v", mgr.cfg.Http, err)
+ Fatalf("failed to listen on %v: %v", mgr.cfg.HTTP, err)
}
Logf(0, "serving http on http://%v", ln.Addr())
go func() {
@@ -198,7 +198,7 @@ func (mgr *Manager) httpCover(w http.ResponseWriter, r *http.Request) {
}
}
- if err := generateCoverHtml(w, mgr.cfg.Vmlinux, cov); err != nil {
+ if err := generateCoverHTML(w, mgr.cfg.Vmlinux, cov); err != nil {
http.Error(w, fmt.Sprintf("failed to generate coverage profile: %v", err), http.StatusInternalServerError)
return
}
@@ -297,7 +297,7 @@ func (mgr *Manager) httpRawCover(w http.ResponseWriter, r *http.Request) {
mgr.mu.Lock()
defer mgr.mu.Unlock()
- base, err := getVmOffset(mgr.cfg.Vmlinux)
+ base, err := getVMOffset(mgr.cfg.Vmlinux)
if err != nil {
http.Error(w, fmt.Sprintf("failed to get vmlinux base: %v", err), http.StatusInternalServerError)
return
diff --git a/syz-manager/manager.go b/syz-manager/manager.go
index aaadbcd3a..b6c70f365 100644
--- a/syz-manager/manager.go
+++ b/syz-manager/manager.go
@@ -68,9 +68,9 @@ type Manager struct {
enabledSyscalls string
enabledCalls []string // as determined by fuzzer
- candidates []RpcCandidate // untriaged inputs from corpus and hub
+ candidates []RPCCandidate // untriaged inputs from corpus and hub
disabledHashes map[string]struct{}
- corpus map[string]RpcInput
+ corpus map[string]RPCInput
corpusCover cover.Cover
corpusSignal signal.Signal
maxSignal signal.Signal
@@ -78,7 +78,7 @@ type Manager struct {
newRepros [][]byte
fuzzers map[string]*Fuzzer
- hub *RpcClient
+ hub *RPCClient
hubCorpus map[hash.Sig]bool
needMoreRepros chan chan bool
hubReproQueue chan *Crash
@@ -105,7 +105,7 @@ const currentDBVersion = 2
type Fuzzer struct {
name string
- inputs []RpcInput
+ inputs []RPCInput
newMaxSignal signal.Signal
}
@@ -166,7 +166,7 @@ func RunManager(cfg *mgrconfig.Config, target *prog.Target, syscalls map[int]boo
stats: make(map[string]uint64),
crashTypes: make(map[string]bool),
enabledSyscalls: enabledSyscalls,
- corpus: make(map[string]RpcInput),
+ corpus: make(map[string]RPCInput),
disabledHashes: make(map[string]struct{}),
fuzzers: make(map[string]*Fuzzer),
fresh: true,
@@ -216,14 +216,14 @@ func RunManager(cfg *mgrconfig.Config, target *prog.Target, syscalls map[int]boo
}
if disabled {
// This program contains a disabled syscall.
- // We won't execute it, but remeber its hash so
+ // We won't execute it, but remember its hash so
// it is not deleted during minimization.
// TODO: use mgr.enabledCalls which accounts for missing devices, etc.
// But it is available only after vm check.
mgr.disabledHashes[hash.String(rec.Val)] = struct{}{}
continue
}
- mgr.candidates = append(mgr.candidates, RpcCandidate{
+ mgr.candidates = append(mgr.candidates, RPCCandidate{
Prog: rec.Val,
Minimized: minimized,
Smashed: smashed,
@@ -247,11 +247,11 @@ func RunManager(cfg *mgrconfig.Config, target *prog.Target, syscalls map[int]boo
}
// Create HTTP server.
- mgr.initHttp()
+ mgr.initHTTP()
mgr.collectUsedFiles()
// Create RPC server for fuzzers.
- s, err := NewRpcServer(cfg.Rpc, mgr)
+ s, err := NewRPCServer(cfg.RPC, mgr)
if err != nil {
Fatalf("failed to create rpc server: %v", err)
}
@@ -802,17 +802,16 @@ func (mgr *Manager) getReporter() report.Reporter {
func (mgr *Manager) minimizeCorpus() {
if mgr.cfg.Cover && len(mgr.corpus) != 0 {
- inputs := make([]signal.SignalContext, 0, len(mgr.corpus))
-
+ inputs := make([]signal.Context, 0, len(mgr.corpus))
for _, inp := range mgr.corpus {
- inputs = append(inputs, signal.SignalContext{
+ inputs = append(inputs, signal.Context{
Signal: inp.Signal.Deserialize(),
Context: inp,
})
}
- newCorpus := make(map[string]RpcInput)
+ newCorpus := make(map[string]RPCInput)
for _, ctx := range signal.Minimize(inputs) {
- inp := ctx.(RpcInput)
+ inp := ctx.(RPCInput)
newCorpus[hash.String(inp.Prog)] = inp
}
Logf(1, "minimized corpus: %v -> %v", len(mgr.corpus), len(newCorpus))
@@ -937,9 +936,9 @@ func (mgr *Manager) NewInput(a *NewInputArgs, r *int) error {
Fatalf("fuzzer %v is not connected", a.Name)
}
- if _, err := mgr.target.Deserialize(a.RpcInput.Prog); err != nil {
+ if _, err := mgr.target.Deserialize(a.RPCInput.Prog); err != nil {
// This should not happen, but we see such cases episodically, reason unknown.
- Logf(0, "failed to deserialize program from fuzzer: %v\n%s", err, a.RpcInput.Prog)
+ Logf(0, "failed to deserialize program from fuzzer: %v\n%s", err, a.RPCInput.Prog)
return nil
}
if mgr.corpusSignal.Diff(inputSignal).Empty() {
@@ -948,19 +947,19 @@ func (mgr *Manager) NewInput(a *NewInputArgs, r *int) error {
mgr.stats["manager new inputs"]++
mgr.corpusSignal.Merge(inputSignal)
mgr.corpusCover.Merge(a.Cover)
- sig := hash.String(a.RpcInput.Prog)
+ sig := hash.String(a.RPCInput.Prog)
if inp, ok := mgr.corpus[sig]; ok {
// The input is already present, but possibly with diffent signal/coverage/call.
inputSignal.Merge(inp.Signal.Deserialize())
inp.Signal = inputSignal.Serialize()
var inputCover cover.Cover
inputCover.Merge(inp.Cover)
- inputCover.Merge(a.RpcInput.Cover)
+ inputCover.Merge(a.RPCInput.Cover)
inp.Cover = inputCover.Serialize()
mgr.corpus[sig] = inp
} else {
- mgr.corpus[sig] = a.RpcInput
- mgr.corpusDB.Save(sig, a.RpcInput.Prog, 0)
+ mgr.corpus[sig] = a.RPCInput
+ mgr.corpusDB.Save(sig, a.RPCInput.Prog, 0)
if err := mgr.corpusDB.Flush(); err != nil {
Logf(0, "failed to save corpus database: %v", err)
}
@@ -968,7 +967,7 @@ func (mgr *Manager) NewInput(a *NewInputArgs, r *int) error {
if f1 == f {
continue
}
- inp := a.RpcInput
+ inp := a.RPCInput
inp.Cover = nil // Don't send coverage back to all fuzzers.
f1.inputs = append(f1.inputs, inp)
}
@@ -1068,12 +1067,12 @@ func (mgr *Manager) hubSync() {
// Hub.Connect request can be very large, so do it on a transient connection
// (rpc connection buffers never shrink).
// Also don't do hub rpc's under the mutex -- hub can be slow or inaccessible.
- if err := RpcCall(mgr.cfg.Hub_Addr, "Hub.Connect", a, nil); err != nil {
+ if err := RPCCall(mgr.cfg.Hub_Addr, "Hub.Connect", a, nil); err != nil {
mgr.mu.Lock()
Logf(0, "Hub.Connect rpc failed: %v", err)
return
}
- conn, err := NewRpcClient(mgr.cfg.Hub_Addr)
+ conn, err := NewRPCClient(mgr.cfg.Hub_Addr)
if err != nil {
mgr.mu.Lock()
Logf(0, "failed to connect to hub at %v: %v", mgr.cfg.Hub_Addr, err)
@@ -1154,7 +1153,7 @@ func (mgr *Manager) hubSync() {
dropped++
continue
}
- mgr.candidates = append(mgr.candidates, RpcCandidate{
+ mgr.candidates = append(mgr.candidates, RPCCandidate{
Prog: inp,
Minimized: false, // don't trust programs from hub
Smashed: false,
@@ -1191,7 +1190,7 @@ func (mgr *Manager) collectUsedFiles() {
addUsedFile(cfg.SyzFuzzerBin)
addUsedFile(cfg.SyzExecprogBin)
addUsedFile(cfg.SyzExecutorBin)
- addUsedFile(cfg.Sshkey)
+ addUsedFile(cfg.SSHKey)
addUsedFile(cfg.Vmlinux)
if cfg.Image != "9p" {
addUsedFile(cfg.Image)
@@ -1211,7 +1210,7 @@ func (mgr *Manager) checkUsedFiles() {
}
func (mgr *Manager) dashboardReporter() {
- webAddr := publicWebAddr(mgr.cfg.Http)
+ webAddr := publicWebAddr(mgr.cfg.HTTP)
var lastFuzzingTime time.Duration
var lastCrashes, lastExecs uint64
for {
diff --git a/syz-manager/mgrconfig/mgrconfig.go b/syz-manager/mgrconfig/mgrconfig.go
index e664267c5..e768c2ab4 100644
--- a/syz-manager/mgrconfig/mgrconfig.go
+++ b/syz-manager/mgrconfig/mgrconfig.go
@@ -13,22 +13,22 @@ import (
"github.com/google/syzkaller/pkg/config"
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/prog"
- _ "github.com/google/syzkaller/sys"
+ _ "github.com/google/syzkaller/sys" // most mgrconfig users want targets too
"github.com/google/syzkaller/vm"
)
type Config struct {
Name string // Instance name (used for identification and as GCE instance prefix)
Target string // Target OS/arch, e.g. "linux/arm64" or "linux/amd64/386" (amd64 OS with 386 test process)
- Http string // TCP address to serve HTTP stats page (e.g. "localhost:50000")
- Rpc string // TCP address to serve RPC for fuzzer processes (optional)
+ HTTP string // TCP address to serve HTTP stats page (e.g. "localhost:50000")
+ RPC string // TCP address to serve RPC for fuzzer processes (optional)
Workdir string
Vmlinux string
Kernel_Src string // kernel source directory
Tag string // arbitrary optional tag that is saved along with crash reports (e.g. branch/commit)
Image string // linux image for VMs
- Sshkey string // ssh key for the image (may be empty for some VM types)
- Ssh_User string // ssh user ("root" by default)
+ SSHKey string // ssh key for the image (may be empty for some VM types)
+ SSH_User string // ssh user ("root" by default)
Hub_Client string
Hub_Addr string
@@ -84,11 +84,11 @@ func LoadFile(filename string) (*Config, error) {
func DefaultValues() *Config {
return &Config{
- Ssh_User: "root",
+ SSH_User: "root",
Cover: true,
Reproduce: true,
Sandbox: "setuid",
- Rpc: ":0",
+ RPC: ":0",
Procs: 1,
}
}
@@ -130,7 +130,7 @@ func load(data []byte, filename string) (*Config, error) {
if !osutil.IsExist(cfg.SyzExecutorBin) {
return nil, fmt.Errorf("bad config syzkaller param: can't find %v", cfg.SyzExecutorBin)
}
- if cfg.Http == "" {
+ if cfg.HTTP == "" {
return nil, fmt.Errorf("config param http is empty")
}
if cfg.Workdir == "" {
@@ -276,8 +276,8 @@ func CreateVMEnv(cfg *Config, debug bool) *vm.Env {
Arch: cfg.TargetVMArch,
Workdir: cfg.Workdir,
Image: cfg.Image,
- SshKey: cfg.Sshkey,
- SshUser: cfg.Ssh_User,
+ SSHKey: cfg.SSHKey,
+ SSHUser: cfg.SSH_User,
Debug: debug,
Config: cfg.VM,
}
diff --git a/tools/syz-crush/crush.go b/tools/syz-crush/crush.go
index 8811d4f4a..d65e1bc5b 100644
--- a/tools/syz-crush/crush.go
+++ b/tools/syz-crush/crush.go
@@ -124,5 +124,4 @@ func runInstance(cfg *mgrconfig.Config, reporter report.Reporter, vmPool *vm.Poo
log.Logf(0, "vm-%v: crashed: %v, saving to %v", index, rep.Title, f.Name())
f.Write(rep.Output)
}
- return
}
diff --git a/tools/syz-execprog/execprog.go b/tools/syz-execprog/execprog.go
index 828dffa51..9373bc8b6 100644
--- a/tools/syz-execprog/execprog.go
+++ b/tools/syz-execprog/execprog.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// execprog executes a single program or a set of programs
-// and optinally prints information about execution.
+// and optionally prints information about execution.
package main
import (
diff --git a/vm/adb/adb.go b/vm/adb/adb.go
index 19a9aa68c..d9ba3f499 100644
--- a/vm/adb/adb.go
+++ b/vm/adb/adb.go
@@ -276,7 +276,7 @@ func (inst *instance) adb(args ...string) ([]byte, error) {
func (inst *instance) repair() error {
// Assume that the device is in a bad state initially and reboot it.
// Ignore errors, maybe we will manage to reboot it anyway.
- inst.waitForSsh()
+ inst.waitForSSH()
// History: adb reboot episodically hangs, so we used a more reliable way:
// using syz-executor to issue reboot syscall. However, this has stopped
// working, probably due to the introduction of seccomp. Therefore,
@@ -289,18 +289,15 @@ func (inst *instance) repair() error {
if !vmimpl.SleepInterruptible(10 * time.Second) {
return fmt.Errorf("shutdown in progress")
}
- if err := inst.waitForSsh(); err != nil {
+ if err := inst.waitForSSH(); err != nil {
return err
}
// Switch to root for userdebug builds.
inst.adb("root")
- if err := inst.waitForSsh(); err != nil {
- return err
- }
- return nil
+ return inst.waitForSSH()
}
-func (inst *instance) waitForSsh() error {
+func (inst *instance) waitForSSH() error {
var err error
for i := 0; i < 300; i++ {
if !vmimpl.SleepInterruptible(time.Second) {
@@ -435,9 +432,9 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
go func() {
select {
case <-time.After(timeout):
- signal(vmimpl.TimeoutErr)
+ signal(vmimpl.ErrTimeout)
case <-stop:
- signal(vmimpl.TimeoutErr)
+ signal(vmimpl.ErrTimeout)
case <-inst.closed:
if inst.debug {
Logf(0, "instance closed")
diff --git a/vm/gce/gce.go b/vm/gce/gce.go
index 5be790b76..bdb7911f8 100644
--- a/vm/gce/gce.go
+++ b/vm/gce/gce.go
@@ -55,11 +55,9 @@ type instance struct {
debug bool
name string
ip string
- offset int64
gceKey string // per-instance private ssh key associated with the instance
sshKey string // ssh key
sshUser string
- workdir string
closed chan bool
}
@@ -155,8 +153,8 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
pool.GCE.DeleteInstance(name, true)
}
}()
- sshKey := pool.env.SshKey
- sshUser := pool.env.SshUser
+ sshKey := pool.env.SSHKey
+ sshUser := pool.env.SSHUser
if sshKey == "" {
// Assuming image supports GCE ssh fanciness.
sshKey = gceKey
@@ -261,7 +259,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
}
if bytes.Contains(output, permissionDeniedMsg) {
// This is a GCE bug.
- break
+ break loop
}
case <-timeout.C:
break loop
@@ -312,9 +310,9 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
go func() {
select {
case <-time.After(timeout):
- signal(vmimpl.TimeoutErr)
+ signal(vmimpl.ErrTimeout)
case <-stop:
- signal(vmimpl.TimeoutErr)
+ signal(vmimpl.ErrTimeout)
case <-inst.closed:
signal(fmt.Errorf("instance closed"))
case err := <-merger.Err:
@@ -330,13 +328,13 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
// Console connection must never fail. If it does, it's either
// instance preemption or a GCE bug. In either case, not a kernel bug.
Logf(1, "%v: gce console connection failed with %v", inst.name, merr.Err)
- err = vmimpl.TimeoutErr
+ err = vmimpl.ErrTimeout
} else {
// Check if the instance was terminated due to preemption or host maintenance.
time.Sleep(5 * time.Second) // just to avoid any GCE races
if !inst.GCE.IsInstanceRunning(inst.name) {
Logf(1, "%v: ssh exited but instance is not running", inst.name)
- err = vmimpl.TimeoutErr
+ err = vmimpl.ErrTimeout
}
}
signal(err)
diff --git a/vm/isolated/isolated.go b/vm/isolated/isolated.go
index 540ce9bce..e0fe6676a 100644
--- a/vm/isolated/isolated.go
+++ b/vm/isolated/isolated.go
@@ -56,8 +56,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
return nil, fmt.Errorf("config param target_dir is empty")
}
// sshkey is optional
- if env.SshKey != "" && !osutil.IsExist(env.SshKey) {
- return nil, fmt.Errorf("ssh key '%v' does not exist", env.SshKey)
+ if env.SSHKey != "" && !osutil.IsExist(env.SSHKey) {
+ return nil, fmt.Errorf("ssh key '%v' does not exist", env.SSHKey)
}
for _, target := range cfg.Targets {
if _, _, err := splitTargetPort(target); err != nil {
@@ -82,11 +82,11 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
target, targetPort, _ := splitTargetPort(pool.cfg.Targets[index])
inst := &instance{
cfg: pool.cfg,
- target: pool.env.SshUser + "@" + target,
+ target: pool.env.SSHUser + "@" + target,
targetPort: targetPort,
closed: make(chan bool),
debug: pool.env.Debug,
- sshkey: pool.env.SshKey,
+ sshkey: pool.env.SSHKey,
}
closeInst := inst
defer func() {
@@ -171,8 +171,8 @@ func (inst *instance) ssh(command string) ([]byte, error) {
func (inst *instance) repair() error {
Logf(2, "isolated: trying to ssh")
- if err := inst.waitForSsh(30 * 60); err == nil {
- if inst.cfg.Target_Reboot == true {
+ if err := inst.waitForSSH(30 * 60); err == nil {
+ if inst.cfg.Target_Reboot {
Logf(2, "isolated: trying to reboot")
inst.ssh("reboot") // reboot will return an error, ignore it
if err := inst.waitForReboot(5 * 60); err != nil {
@@ -180,7 +180,7 @@ func (inst *instance) repair() error {
return err
}
Logf(2, "isolated: rebooted wait for comeback")
- if err := inst.waitForSsh(30 * 60); err != nil {
+ if err := inst.waitForSSH(30 * 60); err != nil {
Logf(2, "isolated: machine did not comeback")
return err
}
@@ -196,7 +196,7 @@ func (inst *instance) repair() error {
return nil
}
-func (inst *instance) waitForSsh(timeout int) error {
+func (inst *instance) waitForSSH(timeout int) error {
var err error
start := time.Now()
for {
@@ -319,9 +319,9 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
go func() {
select {
case <-time.After(timeout):
- signal(vmimpl.TimeoutErr)
+ signal(vmimpl.ErrTimeout)
case <-stop:
- signal(vmimpl.TimeoutErr)
+ signal(vmimpl.ErrTimeout)
case <-inst.closed:
if inst.debug {
Logf(0, "instance closed")
diff --git a/vm/kvm/kvm.go b/vm/kvm/kvm.go
index 634870357..597dd5bfe 100644
--- a/vm/kvm/kvm.go
+++ b/vm/kvm/kvm.go
@@ -33,7 +33,7 @@ type Config struct {
Lkvm string // lkvm binary name
Kernel string // e.g. arch/x86/boot/bzImage
Cmdline string // kernel command line
- Cpu int // number of VM CPUs
+ CPU int // number of VM CPUs
Mem int // amount of VM memory in MBs
}
@@ -79,8 +79,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if !osutil.IsExist(cfg.Kernel) {
return nil, fmt.Errorf("kernel file '%v' does not exist", cfg.Kernel)
}
- if cfg.Cpu < 1 || cfg.Cpu > 1024 {
- return nil, fmt.Errorf("invalid config param cpu: %v, want [1-1024]", cfg.Cpu)
+ if cfg.CPU < 1 || cfg.CPU > 1024 {
+ return nil, fmt.Errorf("invalid config param cpu: %v, want [1-1024]", cfg.CPU)
}
if cfg.Mem < 128 || cfg.Mem > 1048576 {
return nil, fmt.Errorf("invalid config param mem: %v, want [128-1048576]", cfg.Mem)
@@ -134,7 +134,7 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
"--kernel", inst.cfg.Kernel,
"--params", "slub_debug=UZ "+inst.cfg.Cmdline,
"--mem", strconv.Itoa(inst.cfg.Mem),
- "--cpus", strconv.Itoa(inst.cfg.Cpu),
+ "--cpus", strconv.Itoa(inst.cfg.CPU),
"--network", "mode=user",
"--sandbox", scriptPath,
)
@@ -260,10 +260,10 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
for {
select {
case <-timeoutTicker.C:
- resultErr = vmimpl.TimeoutErr
+ resultErr = vmimpl.ErrTimeout
break loop
case <-stop:
- resultErr = vmimpl.TimeoutErr
+ resultErr = vmimpl.ErrTimeout
break loop
case <-secondTicker.C:
if !osutil.IsExist(cmdFile) {
diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go
index 5f945ece8..ce5fe2ec2 100644
--- a/vm/qemu/qemu.go
+++ b/vm/qemu/qemu.go
@@ -36,7 +36,7 @@ type Config struct {
Kernel string // kernel for injected boot (e.g. arch/x86/boot/bzImage)
Cmdline string // kernel command line (can only be specified with kernel)
Initrd string // linux initial ramdisk. (optional)
- Cpu int // number of VM CPUs
+ CPU int // number of VM CPUs
Mem int // amount of VM memory in MBs
}
@@ -127,12 +127,12 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if !osutil.IsExist(env.Image) {
return nil, fmt.Errorf("image file '%v' does not exist", env.Image)
}
- if !osutil.IsExist(env.SshKey) {
- return nil, fmt.Errorf("ssh key '%v' does not exist", env.SshKey)
+ if !osutil.IsExist(env.SSHKey) {
+ return nil, fmt.Errorf("ssh key '%v' does not exist", env.SSHKey)
}
}
- if cfg.Cpu <= 0 || cfg.Cpu > 1024 {
- return nil, fmt.Errorf("bad qemu cpu: %v, want [1-1024]", cfg.Cpu)
+ if cfg.CPU <= 0 || cfg.CPU > 1024 {
+ return nil, fmt.Errorf("bad qemu cpu: %v, want [1-1024]", cfg.CPU)
}
if cfg.Mem < 128 || cfg.Mem > 1048576 {
return nil, fmt.Errorf("bad qemu mem: %v, want [128-1048576]", cfg.Mem)
@@ -151,8 +151,8 @@ func (pool *Pool) Count() int {
}
func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
- sshkey := pool.env.SshKey
- sshuser := pool.env.SshUser
+ sshkey := pool.env.SSHKey
+ sshuser := pool.env.SSHUser
if pool.env.Image == "9p" {
sshkey = filepath.Join(workdir, "key")
sshuser = "root"
@@ -244,19 +244,19 @@ func (inst *instance) Boot() error {
"-serial", "stdio",
"-no-reboot",
}
- if inst.cfg.Cpu == 1 {
+ if inst.cfg.CPU == 1 {
args = append(args,
"-smp", "cpus=1,maxcpus=2",
)
} else {
ncores := 1
- if inst.cfg.Cpu >= 4 {
+ if inst.cfg.CPU >= 4 {
ncores = 2
}
args = append(args,
"-numa", "node,nodeid=0", "-numa", "node,nodeid=1",
"-smp", fmt.Sprintf("cpus=%v,maxcpus=%v,sockets=2,cores=%v",
- inst.cfg.Cpu, inst.cfg.Cpu+1, ncores),
+ inst.cfg.CPU, inst.cfg.CPU+1, ncores),
)
}
args = append(args, strings.Split(inst.cfg.Qemu_Args, " ")...)
@@ -464,9 +464,9 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
go func() {
select {
case <-time.After(timeout):
- signal(vmimpl.TimeoutErr)
+ signal(vmimpl.ErrTimeout)
case <-stop:
- signal(vmimpl.TimeoutErr)
+ signal(vmimpl.ErrTimeout)
case err := <-inst.merger.Err:
cmd.Process.Kill()
if cmdErr := cmd.Wait(); cmdErr == nil {
diff --git a/vm/vm.go b/vm/vm.go
index 389b792c6..c6bc64f05 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -18,6 +18,7 @@ import (
"github.com/google/syzkaller/pkg/report"
"github.com/google/syzkaller/vm/vmimpl"
+ // Import all VM implementations, so that users only need to import vm.
_ "github.com/google/syzkaller/vm/adb"
_ "github.com/google/syzkaller/vm/gce"
_ "github.com/google/syzkaller/vm/isolated"
@@ -41,7 +42,7 @@ type Env vmimpl.Env
var (
Shutdown = vmimpl.Shutdown
- TimeoutErr = vmimpl.TimeoutErr
+ ErrTimeout = vmimpl.ErrTimeout
)
type BootErrorer interface {
@@ -181,7 +182,7 @@ func MonitorExecution(outc <-chan []byte, errc <-chan error, reporter report.Rep
// The program has exited without errors,
// but wait for kernel output in case there is some delayed oops.
return extractError("")
- case TimeoutErr:
+ case ErrTimeout:
return nil
default:
// Note: connection lost can race with a kernel oops message.
@@ -191,11 +192,11 @@ func MonitorExecution(outc <-chan []byte, errc <-chan error, reporter report.Rep
case out := <-outc:
output = append(output, out...)
// syz-fuzzer output
- if bytes.Index(output[matchPos:], []byte("executing program")) != -1 {
+ if bytes.Contains(output[matchPos:], []byte("executing program")) {
lastExecuteTime = time.Now()
}
// syz-execprog output
- if bytes.Index(output[matchPos:], []byte("executed programs:")) != -1 {
+ if bytes.Contains(output[matchPos:], []byte("executed programs:")) {
lastExecuteTime = time.Now()
}
if reporter.ContainsCrash(output[matchPos:]) {
diff --git a/vm/vmimpl/merger_test.go b/vm/vmimpl/merger_test.go
index dd44af57f..b8ae9dfc3 100644
--- a/vm/vmimpl/merger_test.go
+++ b/vm/vmimpl/merger_test.go
@@ -76,7 +76,7 @@ func TestMerger(t *testing.T) {
merger.Wait()
want := "111333\n222555\n666\n444\n777\n"
- if got := string(tee.Bytes()); got != want {
+ if got := tee.String(); got != want {
t.Fatalf("bad tee: '%s', want '%s'", got, want)
}
}
diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go
index 2e3833d89..4565d173e 100644
--- a/vm/vmimpl/vmimpl.go
+++ b/vm/vmimpl/vmimpl.go
@@ -33,7 +33,7 @@ type Instance interface {
// Run runs cmd inside of the VM (think of ssh cmd).
// outc receives combined cmd and kernel console output.
- // errc receives either command Wait return error or vmimpl.TimeoutErr.
+ // errc receives either command Wait return error or vmimpl.ErrTimeout.
// Command is terminated after timeout. Send on the stop chan can be used to terminate it earlier.
Run(timeout time.Duration, stop <-chan bool, command string) (outc <-chan []byte, errc <-chan error, err error)
@@ -50,8 +50,8 @@ type Env struct {
Arch string // target arch
Workdir string
Image string
- SshKey string
- SshUser string
+ SSHKey string
+ SSHUser string
Debug bool
Config []byte // json-serialized VM-type-specific config
}
@@ -87,7 +87,7 @@ func Register(typ string, ctor ctorFunc) {
var (
// Close to interrupt all pending operations in all VMs.
Shutdown = make(chan struct{})
- TimeoutErr = errors.New("timeout")
+ ErrTimeout = errors.New("timeout")
ctors = make(map[string]ctorFunc)
)