aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ipc
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/ipc')
-rw-r--r--pkg/ipc/ipc.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go
index ebdca1ef8..818c88a84 100644
--- a/pkg/ipc/ipc.go
+++ b/pkg/ipc/ipc.go
@@ -16,6 +16,8 @@ import (
"unsafe"
"github.com/google/syzkaller/pkg/cover"
+ "github.com/google/syzkaller/pkg/csource"
+ "github.com/google/syzkaller/pkg/host"
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/pkg/signal"
"github.com/google/syzkaller/prog"
@@ -154,6 +156,45 @@ func FlagsToSandbox(flags EnvFlags) string {
return "none"
}
+// nolint: gocyclo
+func FeaturesToFlags(feat *host.Features, manual csource.Features) EnvFlags {
+ var flags EnvFlags
+ if manual == nil || manual["net_reset"].Enabled {
+ flags |= FlagEnableNetReset
+ }
+ if manual == nil || manual["cgroups"].Enabled {
+ flags |= FlagEnableCgroups
+ }
+ if manual == nil || manual["close_fds"].Enabled {
+ flags |= FlagEnableCloseFds
+ }
+ if feat[host.FeatureExtraCoverage].Enabled {
+ flags |= FlagExtraCover
+ }
+ if feat[host.FeatureDelayKcovMmap].Enabled {
+ flags |= FlagDelayKcovMmap
+ }
+ if feat[host.FeatureNetInjection].Enabled && (manual == nil || manual["tun"].Enabled) {
+ flags |= FlagEnableTun
+ }
+ if feat[host.FeatureNetDevices].Enabled && (manual == nil || manual["net_dev"].Enabled) {
+ flags |= FlagEnableNetDev
+ }
+ if feat[host.FeatureDevlinkPCI].Enabled && (manual == nil || manual["devlink_pci"].Enabled) {
+ flags |= FlagEnableDevlinkPCI
+ }
+ if feat[host.FeatureNicVF].Enabled && (manual == nil || manual["nic_vf"].Enabled) {
+ flags |= FlagEnableNicVF
+ }
+ if feat[host.FeatureVhciInjection].Enabled && (manual == nil || manual["vhci"].Enabled) {
+ flags |= FlagEnableVhciInjection
+ }
+ if feat[host.FeatureWifiEmulation].Enabled && (manual == nil || manual["wifi"].Enabled) {
+ flags |= FlagEnableWifi
+ }
+ return flags
+}
+
func MakeEnv(config *Config, pid int) (*Env, error) {
if config.Timeouts.Slowdown == 0 || config.Timeouts.Scale == 0 ||
config.Timeouts.Syscall == 0 || config.Timeouts.Program == 0 {