vmm: one-shot mode allocates CIDs outside the IdPool and is invisible to the VMM
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- rust
- Área
- infrastructure
Línea de trabajo
Empieza por vmm/src/one_shot.rs, especialmente por run_one_shot y el escaneo de CID, y luego sigue app.rs reload_vms/reload_vms_sync y crates/dstackup/src/cid.rs. Compara los enfoques de coordinación propuestos y determina cómo deberían representarse los CIDs one-shot en la maquinaria de asignación existente. Se considera terminado cuando las asignaciones simultáneas one-shot y del servicio principal no pueden seleccionar el mismo CID.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
One-shot mode (vmm/src/one_shot.rs) and the main VMM service allocate vsock CIDs from the same configured range through two mechanisms that do not know about each other. Nothing prevents them from picking the same CID.
The two allocators
Main service — IdPool over [cid_start, cid_start + cid_pool_size), rebuilt on reload from the supervisor's process list (app.rs, reload_vms / reload_vms_sync).
One-shot — one_shot.rs:24-56:
// scan `ps aux` for qemu-system-x86_64 ... guest-cid=<n>
let mut one_shot_cid = config.cvm.cid_start;
while existing_cids.contains(&one_shot_cid) {
one_shot_cid += 1;
...
}
It starts at cid_start, avoids collisions by scraping ps aux, and never touches the pool.
Why they can collide
One-shot launches QEMU directly (cmd.status() at the end of run_one_shot) rather than registering the process with the supervisor. occupied_cids in both reload paths is built from supervisor.list(), so a one-shot VM's CID is invisible to the main service and never gets occupied in the pool.
The blindness is one-directional:
| sees the other's CIDs? | via | |
|---|---|---|
| one-shot → main service | yes | ps aux finds the qemu processes |
| main service → one-shot | no | one-shot never reaches the supervisor |
So the main service can allocate a CID that a running one-shot VM already holds.
Two secondary issues in the same code path:
- TOCTOU — the
ps auxscan and the QEMU launch are not atomic; a concurrent allocation in the window collides regardless. - Parsing — CIDs are recovered by string-splitting
ps auxoutput onguest-cid=, which is sensitive to how QEMU arguments are formatted.
Note on #907
Before #907, IdPool::allocate() had an off-by-one that made it skip cid_start entirely, while one-shot starts at cid_start. That incidentally kept the two apart. #907 fixed the off-by-one (correctly — one_shot.rs:48 and crates/dstackup/src/cid.rs both already treat the window as [start, start+size)), which removes the accidental separation.
This is not a regression introduced by #907. The protection only ever held for exactly one one-shot VM: a second one takes cid_start + 1, which was already inside the main pool's allocation range. The underlying problem is that the two allocators were never coordinated.
Possible directions
- Register one-shot processes with the supervisor so the existing pool machinery covers them.
- Reserve a dedicated range for one-shot outside
[cid_start, cid_start + cid_pool_size). - Have one-shot allocate through
IdPoolrather thanps aux.
(1) seems most consistent with how the rest of the system tracks VMs, but one-shot is deliberately a lighter path, so (2) may be the cheaper fix.
Confidence
The code paths are confirmed by reading: one-shot starts at cid_start, does not register with the supervisor, and both reload paths source occupied_cids from supervisor.list() only. Not verified on hardware — I have not observed an actual vsock CID collision, and I do not know how much one-shot mode is used in practice, which bounds how much this matters.
Found while reviewing #907.
- Lenguaje dominante
- Rust
- Estrellas
- 546
- Forks
- 96
- Merge medio
- 19 h 22 min
- PR fusionados (30 d)
- 109
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Dstack-TEE/dstack
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
Dstack-TEE/dstack#1301 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
Dstack-TEE/dstack#1300 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Dstack-TEE/dstack#1299 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Dstack-TEE/dstack#1298 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Dstack-TEE/dstack#1297 ·
Todos los issues de Dstack-TEE/dstack
Issues similares
-
risk:low runtime status:in-progress type:test
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
EricSpencer00/Resilient#4835 · 1 comentario ·
-
agent:ready documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
cesarferreira/stax#890 ·
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100