openvmm: virtiofs: renaming a path onto itself drops all tracked aliases at or below that path
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- operating-systems
Research direction
Start at VirtioFs::rename in vm/devices/virtio/virtiofs/src/lib.rs (~lines 532-546); the non-exchange branch calls remove_alias_prefix then rename_alias_prefix, so short-circuit when old_path == new_path. Read remove_alias_prefix/rename_alias_prefix in inode.rs and the same simulation in microvm/limits.rs preflight_microvm_rename. Done means a self-rename leaves aliases() untouched and save_microvm_state in microvm/fs.rs no longer fails; add a regression test in the virtiofs crate.
Written by the indexing model from the issue text.
Description
Summary
When a guest renames a directory entry onto the exact same directory and name (old_path == new_path without RENAME_EXCHANGE), the host rename succeeds as a POSIX no-op, but VirtioFs::rename still executes inodes.remove_alias_prefix(inode.volume_id(), &new_path) followed by inodes.rename_alias_prefix(inode.volume_id(), &old_path, &new_path). Because new_path == old_path, remove_alias_prefix deletes every tracked alias at or below old_path before rename_alias_prefix runs, leaving live inodes with empty or incomplete aliases sets even though nothing changed on the host filesystem. Found during formal specification (blocks formal verification).
Root Cause
In VirtioFs::rename, non-exchange renames assume old_path and new_path are distinct and unconditionally purge new_path from the alias table before rewriting old_path to new_path:
let old_path = inode.child_path(name)?;
let new_path = new_inode.child_path(new_name)?;
self.check_writable_entry(&inode, &old_path)?;
self.check_writable_entry(&new_inode, &new_path)?;
let exchange = flags & RENAME_EXCHANGE != 0;
self.preflight_rename_aliases(inode.volume_id(), &old_path, &new_path, exchange)?;
inode.rename(name, &new_inode, new_name, flags)?;
let mut inodes = self.inner.inodes.write();
if exchange {
inodes.exchange_alias_prefixes(inode.volume_id(), &old_path, &new_path);
} else {
inodes.remove_alias_prefix(inode.volume_id(), &new_path);
inodes.rename_alias_prefix(inode.volume_id(), &old_path, &new_path);
}
When old_path == new_path (request.node_id() == new_dir and name == new_name, or two nodes aliasing the same directory with identical child names), the host renameat/renameat2 call with flags == 0 succeeds without modifying the directory entry. Next, VirtioFsInode::remove_alias_prefix removes every alias with prefix new_path (== old_path) from every live inode in that volume, leaving VirtioFsInode::rename_alias_prefix with no matching aliases left to rewrite. The same destructive simulation also runs in InodeMap::preflight_microvm_rename.
Consequence
- MicroVM save/restore failure:
VirtioFs::save_microvm_staterequires!aliases.is_empty()for every live inode, so renaming any looked-up file or non-empty directory onto itself causes subsequent microVM state saves to fail with"inode has no bounded reopenable aliases". - Spurious
ENOENTon multi-link files: If an inode has two hard linksout/aandout/b, renamingout/aontoout/adrops"out/a"fromaliasesand switchespathto"out/b"; subsequently unlinkingout/bleavespathstuck at deleted"out/b"and causes path-based operations (get_attr,open) on the held node to fail withENOENTeven thoughout/astill exists on disk. - Broken path deduplication and alias accounting: On volumes using
DedupKey::Path,InodeMap::rebuild_dedup_keysskips inodes withinode.aliases().is_empty(), causing subsequent lookups to allocate duplicate node IDs for the same live file or directory, while microVM alias-count and byte-budget limits (MAX_ALIASES,MAX_ALIAS_BYTES) no longer account for the dropped paths.
Reproduction
- Configure a microVM virtio-fs share with
writable_paths = ["out"]containingout/existing. FUSE_LOOKUP"out"(out_node) and"out/existing"(file_node);file_nodeinitially hasaliases = {"out/existing"}.- Issue
FUSE_RENAME(orFUSE_RENAME2withflags = 0) from(out_node, "existing")to(out_node, "existing"). - The rename returns
Ok(())andout/existingremains intact on the host, butfs.get_inode(file_node).unwrap().aliases()is now empty ({}), and callingsave_microvm_statefails with"inode has no bounded reopenable aliases".
Related: #1620, #1602, #1601.
- Dominant language
- Rust
- Stars
- 848
- Forks
- 63
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 571
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/nvx
-
area: ci
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area: ci
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
openvmm: virtiofs: aggregate synthetic root st_nlink counts single-file shares as subdirectoriesOpenarea: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/nvx#1632 · 1 comment ·
Maintainers usually reply within 1 day
-
area: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/nvx#1628 · 1 comment ·
Maintainers usually reply within 1 day
-
area: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
microsoft/nvx#1629 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
community differential help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
hffgzktbcc-blip/ounce-core#489 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
pact-foundation/pact-plugins#125 ·
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jolars/panache#627 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
facebookexperimental/hermit#347 ·
Maintainers usually reply within 1 day