aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-07-17 18:53:07 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-07-17 17:07:15 +0000
commit4403a757953225e9180ed7893c2b2e4ee8569766 (patch)
tree8f7a4898f126dbbb38475f43008b4b817d7bd472
parent4226ed6216e68a40f5a24d127372a374e8f04c66 (diff)
syz-manager: simplify used files checking
Don't bloat the manager context and rely on local variables.
-rw-r--r--syz-manager/manager.go22
1 files changed, 6 insertions, 16 deletions
diff --git a/syz-manager/manager.go b/syz-manager/manager.go
index 6ff42bceb..05927bfc4 100644
--- a/syz-manager/manager.go
+++ b/syz-manager/manager.go
@@ -112,10 +112,6 @@ type Manager struct {
externalReproQueue chan *Crash
crashes chan *Crash
- // For checking that files that we are using are not changing under us.
- // Maps file name to modification time.
- usedFiles map[string]time.Time
-
benchMu sync.Mutex
benchFile *os.File
@@ -254,7 +250,6 @@ func RunManager(cfg *mgrconfig.Config) {
fresh: true,
externalReproQueue: make(chan *Crash, 10),
crashes: make(chan *Crash, 10),
- usedFiles: make(map[string]time.Time),
saturatedCalls: make(map[string]bool),
}
@@ -267,8 +262,8 @@ func RunManager(cfg *mgrconfig.Config) {
go mgr.preloadCorpus()
}
mgr.initHTTP() // Creates HTTP server.
- mgr.collectUsedFiles()
go mgr.corpusInputHandler(corpusUpdates)
+ go mgr.trackUsedFiles()
// Create RPC server for fuzzers.
mgr.serv, err = rpcserver.New(mgr.cfg, mgr, *flagDebug)
@@ -318,7 +313,6 @@ func RunManager(cfg *mgrconfig.Config) {
mgr.pool = vm.NewDispatcher(mgr.vmPool, mgr.fuzzerInstance)
mgr.reproMgr = newReproManager(mgr, mgr.vmPool.Count()-mgr.cfg.FuzzingVMs, mgr.cfg.DashboardOnlyRepro)
go mgr.processFuzzingResults(ctx)
- go mgr.checkUsedFiles()
go mgr.reproMgr.Loop(ctx)
mgr.pool.Loop(ctx)
}
@@ -1524,10 +1518,9 @@ func (mgr *Manager) hubIsUnreachable() {
}
}
-func (mgr *Manager) collectUsedFiles() {
- if mgr.vmPool == nil {
- return
- }
+// trackUsedFiles() is checking that the files that syz-manager needs are not changed while it's running.
+func (mgr *Manager) trackUsedFiles() {
+ usedFiles := make(map[string]time.Time) // file name to modification time
addUsedFile := func(f string) {
if f == "" {
return
@@ -1536,7 +1529,7 @@ func (mgr *Manager) collectUsedFiles() {
if err != nil {
log.Fatalf("failed to stat %v: %v", f, err)
}
- mgr.usedFiles[f] = stat.ModTime()
+ usedFiles[f] = stat.ModTime()
}
cfg := mgr.cfg
addUsedFile(cfg.ExecprogBin)
@@ -1548,11 +1541,8 @@ func (mgr *Manager) collectUsedFiles() {
if cfg.Image != "9p" {
addUsedFile(cfg.Image)
}
-}
-
-func (mgr *Manager) checkUsedFiles() {
for range time.NewTicker(30 * time.Second).C {
- for f, mod := range mgr.usedFiles {
+ for f, mod := range usedFiles {
stat, err := os.Stat(f)
if err != nil {
log.Fatalf("failed to stat %v: %v", f, err)