aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/host/host_netbsd.go
blob: e4de2d408c94be4d68c54f0618faeef36e31c927 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package host

import (
	"github.com/google/syzkaller/pkg/osutil"
	"github.com/google/syzkaller/prog"
)

func isSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {
	switch c.CallName {
	case "syz_usb_connect", "syz_usb_disconnect":
		reason := checkUSBEmulation()
		return reason == "", reason
	default:
		return true, ""
	}
}

func init() {
	checkFeature[FeatureCoverage] = unconditionallyEnabled
	checkFeature[FeatureComparisons] = unconditionallyEnabled
	checkFeature[FeatureUSBEmulation] = checkUSBEmulation
	checkFeature[FeatureExtraCoverage] = checkUSBEmulation
	checkFeature[FeatureDelayKcovMmap] = unconditionallyEnabled
	checkFeature[FeatureFault] = checkFault
}

func checkUSBEmulation() string {
	if err := osutil.IsAccessible("/dev/vhci0"); err != nil {
		return err.Error()
	}
	return ""
}

func checkFault() string {
	if err := osutil.IsAccessible("/dev/fault"); err != nil {
		return err.Error()
	}
	return ""
}