vmm: one-shot mode allocates CIDs outside the IdPool and is invisible to the VMM
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- rust
- Lĩnh vực
- infrastructure
Hướng nghiên cứu
Bắt đầu với vmm/src/one_shot.rs, đặc biệt là run_one_shot và quá trình quét CID, sau đó lần theo app.rs reload_vms/reload_vms_sync và crates/dstackup/src/cid.rs. So sánh các phương án điều phối được đề xuất và xác định cách biểu diễn các CID one-shot trong cơ chế phân bổ hiện có. Hoàn thành có nghĩa là các lần phân bổ one-shot và dịch vụ chính diễn ra đồng thời không thể chọn cùng một CID.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Rust
- Star
- 546
- Fork
- 96
- Merge trung bình
- 19 giờ 22 phút
- Pull request đã merge (30 ngày)
- 109
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Dstack-TEE/dstack
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
Dstack-TEE/dstack#1301 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Dstack-TEE/dstack#1300 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Dstack-TEE/dstack#1299 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Dstack-TEE/dstack#1298 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Dstack-TEE/dstack#1297 ·
Tất cả issue của Dstack-TEE/dstack
Issue tương tự
-
risk:low runtime status:in-progress type:test
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
EricSpencer00/Resilient#4835 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
bisq-network/bisq-musig#204 ·
-
agent:ready documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
cesarferreira/stax#890 ·