Skip to content

Commit

Permalink
all: support empty HTTP config
Browse files Browse the repository at this point in the history
We don't really need an HTTP server when running syz-manager during kernel
image testing and when running syz-diff automatically.

Don't require the config to be set and don't start the HTTP server in
this case.
  • Loading branch information
a-nogikh committed Jan 14, 2025
1 parent 0dce240 commit 102e004
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
3 changes: 3 additions & 0 deletions pkg/manager/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type HTTPServer struct {
}

func (serv *HTTPServer) Serve() {
if serv.Cfg.HTTP == "" {
log.Fatalf("starting a disabled HTTP server")
}
if serv.Pool != nil {
serv.Pools = map[string]*vm.Dispatcher{"": serv.Pool}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/mgrconfig/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func Complete(cfg *Config) error {
cfg.TargetArch, "target",
cfg.Workdir, "workdir",
cfg.Syzkaller, "syzkaller",
cfg.HTTP, "http",
cfg.Type, "type",
cfg.SSHUser, "ssh_user",
); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions syz-ci/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,7 @@ func (mgr *Manager) createTestConfig(imageDir string, info *BuildInfo) (*mgrconf
*mgrcfg = *mgr.managercfg
mgrcfg.Name += "-test"
mgrcfg.Tag = info.KernelCommit
// Use designated ports not to collide with the ports of other managers.
mgrcfg.HTTP = fmt.Sprintf("localhost:%v", mgr.mgrcfg.testHTTPPort)
mgrcfg.HTTP = "" // Don't start the HTTP server.
// For GCE VMs, we need to bind to a real networking interface, so no localhost.
mgrcfg.RPC = fmt.Sprintf(":%v", mgr.mgrcfg.testRPCPort)
mgrcfg.Workdir = filepath.Join(imageDir, "workdir")
Expand Down
5 changes: 1 addition & 4 deletions syz-ci/syz-ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ type ManagerConfig struct {
managercfg *mgrconfig.Config

// Auto-assigned ports used by test instances.
testHTTPPort int
testRPCPort int
testRPCPort int
}

type ManagerJobs struct {
Expand Down Expand Up @@ -461,8 +460,6 @@ func loadManagerConfig(cfg *Config, mgr *ManagerConfig) error {
managercfg.RPC = fmt.Sprintf(":%v", cfg.RPCPort)
cfg.RPCPort++
}
mgr.testHTTPPort = cfg.ManagerPort
cfg.ManagerPort++
mgr.testRPCPort = cfg.RPCPort
cfg.RPCPort++
// Note: we don't change Compiler/Ccache because it may be just "gcc" referring
Expand Down
8 changes: 7 additions & 1 deletion syz-manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ func RunManager(mode *Mode, cfg *mgrconfig.Config) {
mgr.cfg.Procs = 1
}
mgr.http = &manager.HTTPServer{
// Note that if cfg.HTTP == "", we don't start the server.
Cfg: cfg,
StartTime: time.Now(),
CrashStore: mgr.crashStore,
Expand Down Expand Up @@ -355,7 +356,9 @@ func RunManager(mode *Mode, cfg *mgrconfig.Config) {
mgr.http.TogglePause = mgr.pool.TogglePause

ctx := vm.ShutdownCtx()
go mgr.http.Serve()
if mgr.cfg.HTTP != "" {
go mgr.http.Serve()
}
go mgr.trackUsedFiles()
go mgr.processFuzzingResults(ctx)
mgr.pool.Loop(ctx)
Expand Down Expand Up @@ -1437,6 +1440,9 @@ func (mgr *Manager) CoverageFilter(modules []*vminfo.KernelModule) []uint64 {
}

func publicWebAddr(addr string) string {
if addr == "" {
return ""
}
_, port, err := net.SplitHostPort(addr)
if err == nil && port != "" {
if host, err := os.Hostname(); err == nil {
Expand Down
24 changes: 13 additions & 11 deletions tools/syz-diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,19 @@ func main() {
new: new,
store: store,
reproAttempts: map[string]int{},
http: &manager.HTTPServer{
}
if newCfg.HTTP != "" {
diffCtx.http = &manager.HTTPServer{
Cfg: newCfg,
StartTime: time.Now(),
DiffStore: store,
},
}
diffCtx.http.Pools = map[string]*vm.Dispatcher{
new.name: new.pool,
base.name: base.pool,
Pools: map[string]*vm.Dispatcher{
new.name: new.pool,
base.name: base.pool,
},
}
new.http = diffCtx.http
}
new.http = diffCtx.http

diffCtx.Loop(ctx)
}

Expand All @@ -116,7 +117,10 @@ type diffContext struct {

func (dc *diffContext) Loop(ctx context.Context) {
reproLoop := manager.NewReproLoop(dc, dc.new.pool.Total()-dc.new.cfg.FuzzingVMs, false)
dc.http.ReproLoop = reproLoop
if dc.http != nil {
dc.http.ReproLoop = reproLoop
go dc.http.Serve()
}
go func() {
// Let both base and patched instances somewhat progress in fuzzing before we take
// VMs away for bug reproduction.
Expand All @@ -128,10 +132,8 @@ func (dc *diffContext) Loop(ctx context.Context) {

go dc.base.Loop()
go dc.new.Loop()
go dc.http.Serve()

runner := &reproRunner{done: make(chan reproRunnerResult, 2), kernel: dc.base}

rareStat := time.NewTicker(5 * time.Minute)
for {
select {
Expand Down

0 comments on commit 102e004

Please sign in to comment.