aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-01-22 12:09:32 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-01-22 18:19:36 +0000
commitef01311589507ea3919e3804f43781eeb0ca9777 (patch)
treec55a9742423f78afcaaf6af2eeb37d8f75830804 /vm
parent9bd8dcda8c7c494d59bd3132a668f4784ea835c6 (diff)
all: refactor pprof endpoint configuration
In some cases (e.g. gVisor instances using host's network namespace) attempts to bind() all syz-fuzzer processes to the same port result in conflicts and fuzzing breakages. Refactor the code to enable custom pprof configuration depending on the vm type. For now, just disable pprof endpoints for gVisor VMs. Once we actually need the feature there, we can generate custom ports for every gVisor VM.
Diffstat (limited to 'vm')
-rw-r--r--vm/gvisor/gvisor.go8
-rw-r--r--vm/vm.go7
-rw-r--r--vm/vmimpl/vmimpl.go5
3 files changed, 20 insertions, 0 deletions
diff --git a/vm/gvisor/gvisor.go b/vm/gvisor/gvisor.go
index 5ca3e0971..45c076b23 100644
--- a/vm/gvisor/gvisor.go
+++ b/vm/gvisor/gvisor.go
@@ -243,6 +243,14 @@ func (inst *instance) Info() ([]byte, error) {
return []byte(info), nil
}
+func (inst *instance) PprofPort() int {
+ // Some of the gVisor instances use the host's network namespace, which
+ // results in conflicting bind operations on the same HTTP port.
+ // Until there's an actual need to debug gVisor VMs with pprof, let's
+ // just disable it.
+ return 0
+}
+
func (inst *instance) runscCmd(add ...string) *exec.Cmd {
cmd := osutil.Command(inst.image, append(inst.args(), add...)...)
cmd.Env = []string{
diff --git a/vm/vm.go b/vm/vm.go
index fc2e0eb2c..434a3da2e 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -187,6 +187,13 @@ func (inst *Instance) Info() ([]byte, error) {
return nil, nil
}
+func (inst *Instance) PprofPort() int {
+ if ii, ok := inst.impl.(vmimpl.PprofPortProvider); ok {
+ return ii.PprofPort()
+ }
+ return vmimpl.PprofPort
+}
+
func (inst *Instance) diagnose(rep *report.Report) ([]byte, bool) {
if rep == nil {
panic("rep is nil")
diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go
index 8b63ca77e..a9afdc1f1 100644
--- a/vm/vmimpl/vmimpl.go
+++ b/vm/vmimpl/vmimpl.go
@@ -67,6 +67,11 @@ type Infoer interface {
Info() ([]byte, error)
}
+// PprofPortProvider is used when the instance wants to define a custom pprof port.
+type PprofPortProvider interface {
+ PprofPort() int
+}
+
// Env contains global constant parameters for a pool of VMs.
type Env struct {
// Unique name