aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-08-05 19:54:10 +0200
committerDmitry Vyukov <dvyukov@google.com>2016-08-05 20:08:44 +0200
commit39350d876d19ab0937511d969844fb9a559dfd8d (patch)
treed1db1f4a595bb7b1184f3f1d59b6e69e2477c599
parent2db4e4554b9e0e541685aa204113afb84ce0289a (diff)
manager: add a special VM type "none"
Type "none" in config says manager to not manage any VMs, and just manage the corpus (it still server RPCs). This is useful when something else manages the VMs and starts fuzzer processes on them.
-rw-r--r--config/config.go20
-rw-r--r--syz-manager/manager.go5
2 files changed, 20 insertions, 5 deletions
diff --git a/config/config.go b/config/config.go
index dca74edb0..b98b481db 100644
--- a/config/config.go
+++ b/config/config.go
@@ -18,7 +18,8 @@ import (
)
type Config struct {
- Http string
+ Http string // TCP address to serve HTTP stats page (e.g. "localhost:50000")
+ Rpc string // TCP address to serve RPC for fuzzer processes (optional, only useful for type "none")
Workdir string
Vmlinux string
Kernel string // e.g. arch/x86/boot/bzImage
@@ -97,8 +98,20 @@ func parse(data []byte) (*Config, map[int]bool, []*regexp.Regexp, error) {
if cfg.Type == "" {
return nil, nil, nil, fmt.Errorf("config param type is empty")
}
- if cfg.Count <= 0 || cfg.Count > 1000 {
- return nil, nil, nil, fmt.Errorf("invalid config param count: %v, want (1, 1000]", cfg.Count)
+ if cfg.Type == "none" {
+ if cfg.Count != 0 {
+ return nil, nil, nil, fmt.Errorf("invalid config param count: %v, type \"none\" does not support param count", cfg.Count)
+ }
+ if cfg.Rpc == "" {
+ return nil, nil, nil, fmt.Errorf("config param rpc is empty (required for type \"none\")")
+ }
+ } else {
+ if cfg.Count <= 0 || cfg.Count > 1000 {
+ return nil, nil, nil, fmt.Errorf("invalid config param count: %v, want (1, 1000]", cfg.Count)
+ }
+ if cfg.Rpc == "" {
+ cfg.Rpc = "localhost:0"
+ }
}
if cfg.Procs <= 0 {
cfg.Procs = 1
@@ -235,6 +248,7 @@ func checkUnknownFields(data []byte) (string, error) {
// we don't have a better way than to enumerate all known fields.
var fields = []string{
"Http",
+ "Rpc",
"Workdir",
"Vmlinux",
"Kernel",
diff --git a/syz-manager/manager.go b/syz-manager/manager.go
index 2005ed7b7..0c80de938 100644
--- a/syz-manager/manager.go
+++ b/syz-manager/manager.go
@@ -141,7 +141,7 @@ func RunManager(cfg *config.Config, syscalls map[int]bool, suppressions []*regex
mgr.initHttp()
// Create RPC server for fuzzers.
- ln, err := net.Listen("tcp", "localhost:0")
+ ln, err := net.Listen("tcp", cfg.Rpc)
if err != nil {
fatalf("failed to listen on localhost:0: %v", err)
}
@@ -162,7 +162,7 @@ func RunManager(cfg *config.Config, syscalls map[int]bool, suppressions []*regex
var shutdown uint32
var wg sync.WaitGroup
- wg.Add(cfg.Count)
+ wg.Add(cfg.Count + 1)
for i := 0; i < cfg.Count; i++ {
first := i == 0
go func() {
@@ -201,6 +201,7 @@ func RunManager(cfg *config.Config, syscalls map[int]bool, suppressions []*regex
c := make(chan os.Signal, 2)
signal.Notify(c, syscall.SIGINT)
<-c
+ wg.Done()
atomic.StoreUint32(&mgr.shutdown, 1)
*flagV = -1 // VMs will fail
logf(-1, "shutting down...")