aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/options.go
diff options
context:
space:
mode:
authorTheOfficialFloW <theflow@google.com>2020-07-30 11:33:48 +0200
committerGitHub <noreply@github.com>2020-07-30 11:33:48 +0200
commitb0947553167615d7bb1b67b22d2d080e5a5ab2cd (patch)
treef3f104edb509ef1cf89c1db3119052f4d7d4e7ae /pkg/csource/options.go
parent233283a191b3c32a48c56928985c8e2cfc004aeb (diff)
all: initialize vhci in linux
* all: initialize vhci in linux * executor/common_linux.h: improve vhci initialization * pkg/repro/repro.go: add missing vhci options * executor/common_linux.h: fix type and add missing header * executor, pkg: do it like NetInjection * pkg/csource/csource.go: do not emit syz_emit_vhci if vhci is not enabled * executor/common_linux.h: fix format string * executor/common_linux.h: initialize with memset For som reason {0} gets complains about missing braces... * executor/common_linux.h: simplify vhci init * executor/common_linux.h: try to bring all available hci devices up * executor/common_linux.h: find which hci device has been registered * executor/common_linux.h: use HCI_VENDOR_PKT response to retrieve device id * sys/linux/dev_vhci.txt: fix structs of inquiry and report packets * executor/common_linux.h: remove unnecessary return statement and check vendor_pkt read size * executor/common_linux.h: remove unnecessary return statement and check vendor_pkt read size * sys/linux/dev_vhci.txt: pack extended_inquiry_info_t * sys/linux/l2cap.txt: add l2cap_conf_opt struct * executor/common_linux.h: just fill bd addr will 0xaa * executor/common_linux.h: just fill bd addr will 0xaa
Diffstat (limited to 'pkg/csource/options.go')
-rw-r--r--pkg/csource/options.go58
1 files changed, 34 insertions, 24 deletions
diff --git a/pkg/csource/options.go b/pkg/csource/options.go
index 00f83157f..cb1a19114 100644
--- a/pkg/csource/options.go
+++ b/pkg/csource/options.go
@@ -31,15 +31,16 @@ type Options struct {
Leak bool `json:"leak,omitempty"` // do leak checking
// These options allow for a more fine-tuned control over the generated C code.
- NetInjection bool `json:"tun,omitempty"`
- NetDevices bool `json:"netdev,omitempty"`
- NetReset bool `json:"resetnet,omitempty"`
- Cgroups bool `json:"cgroups,omitempty"`
- BinfmtMisc bool `json:"binfmt_misc,omitempty"`
- CloseFDs bool `json:"close_fds"`
- KCSAN bool `json:"kcsan,omitempty"`
- DevlinkPCI bool `json:"devlinkpci,omitempty"`
- USB bool `json:"usb,omitempty"`
+ NetInjection bool `json:"tun,omitempty"`
+ NetDevices bool `json:"netdev,omitempty"`
+ NetReset bool `json:"resetnet,omitempty"`
+ Cgroups bool `json:"cgroups,omitempty"`
+ BinfmtMisc bool `json:"binfmt_misc,omitempty"`
+ CloseFDs bool `json:"close_fds"`
+ KCSAN bool `json:"kcsan,omitempty"`
+ DevlinkPCI bool `json:"devlinkpci,omitempty"`
+ USB bool `json:"usb,omitempty"`
+ VhciInjection bool `json:"vhci,omitempty"`
UseTmpDir bool `json:"tmpdir,omitempty"`
HandleSegv bool `json:"segv,omitempty"`
@@ -88,6 +89,9 @@ func (opts Options) Check(OS string) error {
if opts.BinfmtMisc {
return errors.New("option BinfmtMisc without sandbox")
}
+ if opts.VhciInjection {
+ return errors.New("option VhciInjection without sandbox")
+ }
}
if opts.Sandbox == sandboxNamespace && !opts.UseTmpDir {
// This is borken and never worked.
@@ -135,6 +139,9 @@ func (opts Options) checkLinuxOnly(OS string) error {
if opts.USB {
return fmt.Errorf("option USB is not supported on %v", OS)
}
+ if opts.VhciInjection {
+ return fmt.Errorf("option VHCI is not supported on %v", OS)
+ }
if opts.Sandbox == sandboxNamespace ||
(opts.Sandbox == sandboxSetuid && !(OS == openbsd || OS == freebsd || OS == netbsd)) ||
opts.Sandbox == sandboxAndroid {
@@ -151,21 +158,22 @@ func (opts Options) checkLinuxOnly(OS string) error {
func DefaultOpts(cfg *mgrconfig.Config) Options {
opts := Options{
- Threaded: true,
- Collide: true,
- Repeat: true,
- Procs: cfg.Procs,
- Sandbox: cfg.Sandbox,
- NetInjection: true,
- NetDevices: true,
- NetReset: true,
- Cgroups: true,
- BinfmtMisc: true,
- CloseFDs: true,
- DevlinkPCI: true,
- UseTmpDir: true,
- HandleSegv: true,
- Repro: true,
+ Threaded: true,
+ Collide: true,
+ Repeat: true,
+ Procs: cfg.Procs,
+ Sandbox: cfg.Sandbox,
+ NetInjection: true,
+ NetDevices: true,
+ NetReset: true,
+ Cgroups: true,
+ BinfmtMisc: true,
+ CloseFDs: true,
+ DevlinkPCI: true,
+ VhciInjection: true,
+ UseTmpDir: true,
+ HandleSegv: true,
+ Repro: true,
}
if cfg.TargetOS != linux {
opts.NetInjection = false
@@ -176,6 +184,7 @@ func DefaultOpts(cfg *mgrconfig.Config) Options {
opts.CloseFDs = false
opts.DevlinkPCI = false
opts.USB = false
+ opts.VhciInjection = false
}
if cfg.Sandbox == "" || cfg.Sandbox == "setuid" {
opts.NetReset = false
@@ -256,6 +265,7 @@ func defaultFeatures(value bool) Features {
"close_fds": {"close fds after each program", value},
"devlink_pci": {"setup devlink PCI device", value},
"usb": {"setup and use /dev/raw-gadget for USB emulation", value},
+ "vhci": {"setup and use /dev/vhci for hci packet injection", value},
}
}