Skip to content

Commit

Permalink
pkg/host: disable for akaros
Browse files Browse the repository at this point in the history
akaros can't have own host version
because fuzzer does not run on akaros,
so just disable it all.
  • Loading branch information
dvyukov committed Jul 6, 2018
1 parent 00c9774 commit 0b95b8e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
17 changes: 15 additions & 2 deletions pkg/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ func DetectSupportedSyscalls(target *prog.Target, sandbox string) (
map[*prog.Syscall]bool, map[*prog.Syscall]string, error) {
supported := make(map[*prog.Syscall]bool)
unsupported := make(map[*prog.Syscall]string)
// Akaros does not have own host and parasitizes on some other OS.
if target.OS == "akaros" {
for _, c := range target.Syscalls {
supported[c] = true
}
return supported, unsupported, nil
}
for _, c := range target.Syscalls {
ok, reason := isSupported(c, sandbox)
if ok {
Expand Down Expand Up @@ -57,7 +64,7 @@ func unconditionallyEnabled() string { return "" }
// Check detects features supported on the host.
// Empty string for a feature means the feature is supported,
// otherwise the string contains the reason why the feature is not supported.
func Check() (*Features, error) {
func Check(target *prog.Target) (*Features, error) {
const unsupported = "support is not implemented in syzkaller"
res := &Features{
FeatureCoverage: {Name: "code coverage", Reason: unsupported},
Expand All @@ -68,6 +75,9 @@ func Check() (*Features, error) {
FeatureLeakChecking: {Name: "leak checking", Reason: unsupported},
FeatureNetworkInjection: {Name: "net packed injection", Reason: unsupported},
}
if target.OS == "akaros" {
return res, nil
}
for n, check := range checkFeature {
if check == nil {
continue
Expand All @@ -84,7 +94,10 @@ func Check() (*Features, error) {

// Setup enables and does any one-time setup for the requested features on the host.
// Note: this can be called multiple times and must be idempotent.
func Setup(features *Features) (func(), error) {
func Setup(target *prog.Target, features *Features) (func(), error) {
if target.OS == "akaros" {
return nil, nil
}
var callback func()
for n, setup := range setupFeature {
if setup == nil || !features[n].Enabled {
Expand Down
6 changes: 5 additions & 1 deletion pkg/host/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ func TestDetectSupportedSyscalls(t *testing.T) {

func TestCheck(t *testing.T) {
t.Parallel()
features, err := Check()
target, err := prog.GetTarget(runtime.GOOS, runtime.GOARCH)
if err != nil {
t.Fatal(err)
}
features, err := Check(target)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion syz-fuzzer/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func main() {
for _, feat := range r.CheckResult.Features {
log.Logf(0, "%v: %v", feat.Name, feat.Reason)
}
periodicCallback, err := host.Setup(r.CheckResult.Features)
periodicCallback, err := host.Setup(target, r.CheckResult.Features)
if err != nil {
log.Fatalf("BUG: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion syz-fuzzer/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func checkMachine(args *checkArgs) (*rpctype.CheckArgs, error) {
if err := checkRevisions(args); err != nil {
return nil, err
}
features, err := host.Check()
features, err := host.Check(args.target)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions tools/syz-execprog/execprog.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func main() {
return
}

features, err := host.Check()
features, err := host.Check(target)
if err != nil {
log.Fatalf("%v", err)
}
if _, err = host.Setup(features); err != nil {
if _, err = host.Setup(target, features); err != nil {
log.Fatalf("%v", err)
}
config, execOpts := createConfig(target, entries, features)
Expand Down
4 changes: 2 additions & 2 deletions tools/syz-stress/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func main() {
log.Fatalf("nothing to mutate (-generate=false and no corpus)")
}

features, err := host.Check()
features, err := host.Check(target)
if err != nil {
log.Fatalf("%v", err)
}
if _, err = host.Setup(features); err != nil {
if _, err = host.Setup(target, features); err != nil {
log.Fatalf("%v", err)
}

Expand Down

0 comments on commit 0b95b8e

Please sign in to comment.