Repository navigation
fix(vmm): validate image names in one place and before writing the manifest - #1476
Merged
Merged
Conversation
kvinwang
force-pushed
the
fix/vmm-image-name
branch
from
October 23, 2026 04:21
9308afc to
8013d2f
Compare
…nifest Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
force-pushed
the
fix/vmm-image-name
branch
from
October 23, 2026 04:49
8013d2f to
2e0494a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Image names are checked by three hand-written rules, and none rejects
.:DeleteImageonly refuses empty names,..and/.DeleteImage { id: "." }passes,image.path.join(".")exists, andremove_dir_alldeletes every image on the node before failing on the root itself. The in-use check compares against".", so images of running VMs go too:(
ls imagesis empty afterwards.)load_vm/load_or_update_vmuseis_alphanumeric(accepts any Unicode letter) and also accept..UpdateVm/ResizeVmsetmanifest.imageunchecked and write the manifest beforeload_vmvalidates it. A missing or invalid image leaves a manifest that fails to load on every VMM start, so the VM drops out of the inventory.Fix
ImageConfig::image_dir(name)is the single check for the VMM RPC paths: non-empty, at most 64 chars, ASCII[A-Za-z0-9_.-], no leading.. Used byload_vm,load_or_update_vmandDeleteImage.make_sys_configonly runs afterload_vm, and the one-shot CLI keeps accepting a path from its local config file, so both are left as they are.apply_resource_updatesresolves and loads the requested image before it touches the manifest, so a bad image fails the RPC and changes nothing.Names with non-ASCII letters or a leading
.are now refused; image names shipped by dstack are all ASCII.Verification
dstack-vmm(unix socket, temp image dir withimg-a,img-b) and calledDeleteImage {"id":"."}:origin/next: the error above, image dir emptied.{"error": "invalid image name: \".\""}, both images remain.cargo test -p dstack-vmm --all-features: 217 passed, includingimage_dir_stays_a_direct_child_of_the_image_root.cargo clippy -p dstack-vmm --all-features -- -D warnings -D clippy::unwrap_used -D clippy::expect_usedclean.UpdateVm/ResizeVmordering fix is not exercised at runtime (it needs a stopped VM).