[Medium] VM managers hold the global lock during multi-minute provisioning, blocking SSH dialing and teardown for all tenants
Report
Summary
LimaManager.Provision and QEMUManager.Provision hold the manager-wide write lock for their entire duration -- up to ~9 min for Lima (2 min create + 5 min start + 2 min SSH wait) -- while running blocking subprocess calls. During that window every other VM operation blocks: DialSSH (tunnel handler -> SSH access for all tenants stalls), Teardown (settle/cancel cleanup stalls), List/Get (capacity checks, API /vms stall). Provisions serialize on the same lock, so chained leases sustain the blockage.
Root Cause
vm/lima_manager.go:94-96:Provisiontakesm.mu.Lock(),defer m.mu.Unlock()at the top, then runsrunLimactlWithTimeout(2min, "create"),runLimactlWithTimeout(5min, "start"),waitForSSHPort(name, 2min).vm/qemu_manager.go:144-146: same pattern.vm/lima_manager.go:182-185(DialSSHtakesRLock),:164-166(TeardowntakesLock) -- both block while a provision holds the write lock.
Impact
- Remote, cheap trigger:
provisionVM(node/vm.go:74) <-autoAcceptLease<- gossipedBlockLease-- any user creating a lease to the provider triggers it.MaxConcurrentdefaults to 0 = "bounded only by resource capacity" (cmd/xe/main.go:1311), so with minimum-size leases (1 vCPU/512 MB/5 GB) an attacker can queue many provisions; escrow is refundable via cancel. - All tenants' SSH access stalls (tunnel handler calls
DialSSH), teardown stalls (settle/cancel cleanup), capacity checks stall.
Verification (executed PoC)
Fake limactl that sleeps 30 s in create:
List() BLOCKED for >15s while a provision is in flight (lock held)
Get() BLOCKED for >10s while a provision is in flight (lock held)
provision finished, err: get ssh port: ssh port not ready after 2m0s
Audited at HEAD 8cc209d (testnet-0006).
Suggested fix
Hold the lock only for map mutations; do the long subprocess work outside it (e.g. reserve the lease hash, release the lock, provision, re-lock to register). Add a provisioning-state entry so concurrent Provision for the same lease still dedups.
Thread
Thanks. This is the same finding as https://bounty.xe.network/XE-0675, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-16757 and says what differs; it is read like any other.