Repository navigation
[DO NOT REVIEW] virtiofs: close Windows case and 8.3 name bypasses of the microVM policy - #5224
Merged
Pedro Henrique Penna (ppenna) merged 12 commits intoNov 22, 2026
Conversation
FUSE_LINK to a node whose names the guest had all removed, by FUSE_UNLINK or by a FUSE_RENAME over the last one, linked whatever object had since appeared at the node's former path (microsoft/nvx#1608). It recorded the new name for the node and replied with the node's ID and inode number but that object's attributes, so two nodes stood for one object. The object could be a read-only file, which a link through its own node refuses with EXDEV, since a name in a writable path would make the file writable: through the stale node, the guest could give it one. VirtioFsInode::remove_alias_prefix keeps an inode's path when it removes the last alias, since other requests about the node still use it, and VirtioFsInode::link linked the target at that path without checking that it still names the target's object. VirtioFsInode::object_path returns an inode's path only while the guest still knows a name for its object, and fails with ENOENT once the guest has removed them all. VirtioFsInode::link takes the target's path from it, so FUSE_LINK to such a node fails with ENOENT, as Linux's linkat does for an unlinked file, before it changes the host or the node. The check sits where the path is used rather than in the FUSE_LINK handler, so that the other requests about such a node, which still use its former path (microsoft/nvx#1623), can share it. a_link_to_a_node_whose_names_are_gone_links_nothing removes the last name of a file's node on a microVM share, either by unlinking the file and creating another at its name, or by renaming a host hard link of a read-only file over it, and then links the node. Without the fix, at 2b90ba3, microsoft/nvx#1599's fix on feature/microvm/dev b51f915, on Windows and on a Linux KVM host, both links succeed; with it, both fail with ENOENT, create no host entry, and leave the node without names, and the package's tests pass on both hosts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM aggregate's file child whose host path was a bare file name, as `seed.txt`, or a symbolic link to a regular file passed MicroVmAggregateChild::validate_root_path, but attaching it failed (microsoft/nvx#1618): for the bare name, with ENOENT on Linux or EINVAL on Windows, and for the link, with EACCES. The child's identity, which microvm_file_identity computes and validate_root_path checks, is that of the file that the path resolves to, from the current directory and through symbolic links, since both canonicalize the path. open_microvm_volume split the path as given instead: it opened the path's parent, which is empty for a bare name, and exposed the path's last name, which names a link rather than its target, so the lstat of the child's root found a symbolic link, which a file child's volume refuses. open_microvm_volume now resolves a symbolic link at the end of a file child's path to its final target, as the identity does, and makes any other path absolute, which keeps the name that the path gives: on Windows, canonicalization would turn a path to the default stream of a file, `file::$DATA`, into the file's, which the name check of microsoft/nvx#1614 would then accept. That check applies to the name that the volume uses, which for a link is its target's, so a link whose own name has a colon attaches, and a link to a file whose name has one is refused. The OpenVMM command line passes canonical paths and refuses links, so it is unchanged, as are directory shares and children, whose volumes open the directories that their paths resolve to. The saved state is unchanged. Tests, in virtiofs' microVM aggregate tests: a file child given by a bare name in the current directory, by `./` and the name, or on Windows by its drive and the name, attaches, and the guest reads it; one given by an absolute, a relative, or a chained link attaches as the link's target, which the guest reads and writes; and a link to a file that the volume cannot name is refused, on Windows a link to a stream, while on Linux a link with a colon in its own name attaches. Without the fix, on top of that of microsoft/nvx#1614, the bare name fails to attach, with EINVAL on Windows and ENOENT on Linux (Azure Linux 3.0, nvx-kvm-test), the links fail with EACCES, and on Linux the link with a colon in its own name is refused for that name. With it, the new tests and the package's other tests pass on Windows, with native symbolic links allowed for the tests that need them, and on Linux. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FUSE_GETATTR and FUSE_STATX of a microVM aggregate's synthetic root reported a link count of two plus one per child, file children included, so the count disagreed with the root's listing (microsoft/nvx#1632): two file children and a directory child gave 5, where a directory with one subdirectory has 3. A directory's link count is two, for its `.` and the entry that names it, plus one for the `..` of each subdirectory, which find and other fts-based tools use to tell how many subdirectories a directory holds. VirtioFs::synthetic_root_nlink counted every entry of the aggregate's registry, while a read of the root, in VirtioFs::write_child_entry, lists a child that exposes a regular file, a microVM file child, as DT_REG, and every other child as DT_DIR. Count only the children that expose no file, which a read of the root lists as directories. An aggregate without file children, such as any aggregate outside a microVM, reports the same count as before. microvm::aggregate_fs_tests:: synthetic_root_links_only_its_child_directories checks FUSE_GETATTR and FUSE_STATX of the roots of three microVM aggregates, of two file children and a directory child, of the two file children alone, and of two directory children, against two plus the directories that FUSE_READDIR lists: 3, 2, and 4. Without the fix, the test fails on Windows and on Linux (Azure Linux 3.0, nvx-kvm-test), where the first root reports 5; with it, the test and the rest of cargo nextest -p virtiofs pass on both. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
In a user namespace whose setgroups file says "allow", as one that newgidmap maps from a subordinate GID range does, a thread with CAP_SETGID there may drop its supplementary groups. getgroups reports each group that the namespace does not map as the kernel's overflow GID, 65534 by default, and setgroups refuses a GID that the namespace does not map, so a thread can never regain such a group once it drops it. with_fs_identity's switch saved the list that getgroups reported, dropped the groups, and restored the list afterwards: with the overflow GID unmapped, the restore failed with EINVAL and the panic of SwitchedCredentials::drop aborted OpenVMM, and with it mapped, the restore replaced the thread's unmapped groups with the one group that the overflow GID maps to. Position 158's switch dropped groups whenever one differed from the target GID, and the overflow GID change for microsoft/nvx#1600 also drops them when the target GID is the overflow GID. A group that may be unmapped can be neither kept, since it may be any group, nor dropped, since the thread could not regain it. The switch therefore takes the groups from mapped_groups, which fails with EPERM before anything changes whenever a supplementary group reads as the overflow GID in a namespace that may not map every group. That refusal covers the case that the overflow GID change drops groups for, so it replaces may_report_other_groups_as and that drop. mapped_groups reads /proc/self/gid_map, about 3.4 us on an Azure Linux 3 test VM, for a thread with supplementary groups, and the initial user namespace, which maps every ID, needs nothing more. In another namespace, it reads the groups again between two reads of the overflow GID, which the administrator may change at any time, and fails unless it can read the overflow GID, both reads agree, and no group has that GID. The virtio-fs Guide says that such a namespace fails every request that runs as its caller. unmapped_groups_fail_closed_with_privilege, which requires CAP_SETGID, gives a child process a group, maps the child's new user namespace without denying setgroups and without that group, and runs the test again as the namespace's root. There, a switch to the child's own identity must fail with EPERM without running the operation, and the child must keep the unmapped group, as chmod's handling of S_ISGID on a file of that group shows, whether the namespace leaves the overflow GID unmapped, maps it to another group, or maps it to the child's own GID; the test reports every layout that fails. Run as root on an Azure Linux 3 VM with kernel 6.18.57 and the default overflow GID, it failed in all three layouts without this change: the first panicked with "failed to restore the thread's supplementary groups: Error(EINVAL (22))", and the others returned Ok(()) rather than EPERM. With the change, it passes. The unprivileged overflow GID test of microsoft/nvx#1600 now fails at the refusal rather than at setgroups. Fold into position 158 at the next reorganization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fsync and fdatasync of a descriptor of an aggregate's synthetic root, as `sync` calls for a directory that it is given, failed with EBADF, which POSIX reserves for a descriptor that is not open (microsoft/nvx#1624). The Linux FUSE client sends both as FUSE_FSYNCDIR, with the node of the directory and the handle that FUSE_OPENDIR returned. FUSE_OPENDIR of the synthetic root returns SYNTHETIC_ROOT_FH, which names no open file, and READDIR, READDIRPLUS, and RELEASEDIR, and GETATTR and STATX through a handle, recognize it with the root's node before they look a handle up. VirtioFs::fsync_dir looked it up in the handle map, found nothing, and failed with EBADF. fsync_dir now succeeds for the synthetic root's handle with the root's node, as release_dir does, before it looks a handle up: the root keeps its entries only in memory, so it has nothing to write back. ENOSYS would not do, since the Linux client takes it for the whole mount and stops syncing the children's directories too. Any other handle or node reaches get_file as before. aggregate::tests::synthetic_root_handle_accepts_fsyncdir checks that FUSE_FSYNCDIR through an aggregate root's handle succeeds with and without FUSE_FSYNC_FDATASYNC, and that the handle with a child's node, and another handle with the root's node, still fail with EBADF. At its parent, 655bc31, the change for microsoft/nvx#1606 on the stack of changes above feature/microvm/dev 3288834, the test fails with EBADF on Windows and on a Linux KVM host; with the fix, it and the rest of cargo nextest -p virtiofs pass on both. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM guest could rename a writable directory that holds a denied path, such as logs under --mount-deny logs/secret, and so move the hidden entries to a visible path (microsoft/nvx#1601). There the guest could list and remove them, and open an object that the host had created at the denied path after attaching the share, which HostFs had not pinned. A RENAME_EXCHANGE on a Linux host did the same with the directory as either name. Conversely, once the host had removed such a directory, the guest could rename one of its own onto that name and so put its entries at the denied path, where it cannot create them itself. VirtioFs::rename checked only that the guest may modify the two names that it renames, but a rename also moves everything below its source to its destination, or for an exchange swaps everything below both, and the access policy can hide a path below a writable one. A rename now also requires that the guest may modify every path below both names, and otherwise fails with EROFS before the host changes anything, as the other writes that the policy refuses do. SubtreePolicy::is_subtree_writable decides it: below a writable path, only a denied path hides or protects anything, since an allowed path lies inside a denied one, and a writable path that contains a path contains everything below it. A rename of a name onto itself with a denied path below it fails as well, as any rename does on a read-only share. The Guide describes the restriction. renames_never_move_a_denied_path, in virtiofs' microVM policy tests, renames a directory that holds a denied path, and exchanges it as either name, and renames a directory that holds a denied path inside an allowed path. It checks that each fails with EROFS and changes nothing, and that renames that move no denied path still succeed. renames_never_move_entries_into_a_denied_path renames a guest directory onto the name of a directory that holds a denied path, after the host removed it. A unit test of SubtreePolicy covers nested denied and allowed paths, writable paths, and names that only share a prefix with a denied path's ancestor. Without the fix, both microVM tests fail on Windows and on Linux, where the renames succeed. A scratch test then found the hidden secret listed under each new name, including after either exchange on Linux, and the guest's file at logs/secret; on Windows, the guest also read and removed a secret that the host had recreated after attaching the share. With the fix, the tests and the package's other tests pass on both. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Windows reaches a directory entry not only by its own name, but also by that name in another case, unless the directory is case sensitive, and by the 8.3 short name of a long name. A caller that checks host paths against names, such as the access policy of a microVM virtio-fs share, cannot tell from a path alone which entry it reaches or what that entry's own name is. Add LxVolume::stored_path on Windows. It opens the entry that a path reaches without access, exactly as the other operations resolve the path, so the open neither conflicts with other opens nor breaks their oplocks, and queries its FileNormalizedNameInformation: the path from the volume's root with the long name of each component as the file system stores it. The final components of that path are the stored names of the given path's components, and a missing entry yields None. The query grows its buffer when Windows reports a longer name. Tests, in lxutil on Windows: a path reaches its entry's stored names through a name in another case and through a hard link's own name, a missing entry or ancestor yields None, and on a volume that generates 8.3 short names, as this host's temporary directory does, a short name in either case yields the long name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A Windows host resolves a name in another case to the entry of that name, unless the directory is case sensitive, but a microVM share's SubtreePolicy matched the guest's names against its denied, allowed, and writable paths byte for byte (microsoft/nvx#1603). A name that differed from a protected path only in case therefore passed every policy check and reached the protected entry. With denied_paths = ["marker"] on a read-write share, FUSE_UNLINK of "MARKER" deleted the host's marker; FUSE_RENAME of "LOGS", a traverse-only directory, moved it to a visible name that exposed its hidden entries; and once the host had removed marker, FUSE_CREATE of "MARKER" created the file that the host then opens as marker. A rename also escaped the check that no denied path lies below its source or its destination: with denied_paths = ["logs/secret"], FUSE_RENAME of "LOGS" moved logs, with its hidden secret, to a visible name. Pinned identities could not help: they reject only objects that existed at attach time, and only at lookup. On Windows, SubtreePolicy::visibility, and with it is_writable and every check of VirtioFsVolume, now also matches the policy's paths ignoring case and keeps the more restrictive result. A name that matches a denied path in another case is hidden as the path is, and one that matches a traverse-only directory is traverse-only, so it fails before the host operation as the path's own name does. And is_subtree_writable, which the source and the destination of a rename must pass, also finds the denied paths below a name in another case. Grants never follow another case: such a name exposes no allowed path and makes no writable path writable, so a case-sensitive directory can only hide more. Names match ignoring case when Unicode's full upper-case mappings agree, which equates every pair that a Windows upcase table of simple mappings does, and a few more, which only hide more. The validation of a policy and the identities pinned at attach time still compare the canonical paths exactly, and Linux hosts, which resolve names exactly, keep matching them exactly. Tests: SubtreePolicy unit tests of both name matchings, including non-ASCII letters, a denied and an allowed path that differ only in case, and a denied path below a name in another case; and, in the microVM policy tests on Windows, a denied file in another case fails like its own name for FUSE_UNLINK, FUSE_RENAME of and onto it, FUSE_CREATE, and FUSE_LOOKUP; a denied file that the host removes and recreates cannot be planted, made, or linked in another case, nor looked up or probed by an exclusive create; a traverse-only directory in another case, at the root or inside a writable path, can be neither renamed nor removed; and a directory that holds a denied path can be neither renamed in another case nor, once the host has moved it away, replaced by a guest directory renamed onto its name in another case. Without the fix, on Windows, FUSE_UNLINK of "MARKER" deletes the denied file, FUSE_CREATE of "MARKER" plants a file at the denied path, and FUSE_RENAME of "LOGS" moves both the traverse-only directory and a directory that holds the denied logs/secret; with it, these tests and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A Windows host also resolves the 8.3 short name of a long name, and a name in another case, to the entry. A microVM share's access policy and the names that the guest knows for an object are exact names, so such a name reached an entry that the policy protects under its own name (microsoft/nvx#1603). With denied_paths = ["credentials.json"], whose short name is CREDEN~1.JSO, FUSE_UNLINK and FUSE_RENAME of CREDEN~1.JSO deleted or moved the denied file, FUSE_RENAME onto it replaced it, and once the host had recreated the file, so that no pinned identity covered it, FUSE_LOOKUP and FUSE_CREATE with O_TRUNC of CREDEN~1.JSO exposed and truncated it; at attach time, the pinned identity answered EACCES where a missing name answers ENOENT. A node also kept reaching whatever its name came to reach: after the guest removed its own file named CREDEN~1.JSO and the host recreated the denied file, which took that short name, the guest's node of the removed file opened the denied file. And a name in another case became a name of the object that the policy checks writes through: after FUSE_LOOKUP of "OUT" inside a share whose writable path is out, the guest could no longer create in out. On a strict volume on Windows, the guest now reaches an existing entry only by the names that Windows stores for it, as on Linux. LxVolume::stored_path gives the stored names of the entry that a path reaches. Lookup, unlink, rmdir, and the source of a rename of a guest-supplied name that reaches an entry by other names fail with ENOENT, as for a missing name, and a create that may open an existing entry, without O_EXCL, and the target of a rename, which it would replace, fail with EACCES. A rename of an entry to its own name in another case changes the case of that name. Every operation on a node also checks its names before it reaches the host, and fails with ENOENT once they reach an entry by other names, as after the host changes the case of one; this also holds for the names of a restored node. Lookup checks a name only after the host finds an entry, so a missing name costs nothing more, and before it checks the object against the pinned identities, so a short name of a denied file answers ENOENT whether or not the file exists. An exclusive create, mkdir, mknod, symlink, or link under another name of an existing entry already fails with EEXIST, as Windows refuses it, and READDIRPLUS looks its children up by the names that the host lists, which are their own names, and revalidates their identities, so neither checks a name. Other hosts resolve names exactly, so nothing changes there. A file that denies the VMM's user SYNCHRONIZE access, which every other operation on the file already needs, can no longer be looked up, since the check opens it. Tests, in the microVM policy tests on Windows: names in another case reach no entry, neither remove, move, nor replace one, and no longer make a writable directory read-only, while a rename to an entry's own name in another case renames it; and, on a volume that generates 8.3 short names, as this host's temporary directory does, a short name of a denied file or of a visible one reaches no entry, before and after the host recreates the denied file, a node whose name became the recreated file's short name can neither open nor inspect it, and the file is unchanged. Without the fix, on Windows, FUSE_UNLINK of CREDEN~1.JSO deletes the denied file and FUSE_LOOKUP of "OUT" succeeds, and without the check of a node's names, the node opens the recreated file; with it, these tests and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
requested review from
a team and
Anatol Belski (weltling)
as code owners
November 22, 2026 06:45
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
An aggregate's file child exposes the file that its host path names by the path's last name, which the device keeps as given rather than canonicalizing it (microsoft/nvx#1618), and which the child's identity accepts, since it canonicalizes the path. On Windows, that name may be the file's own name in another case or its 8.3 short name, which Windows resolves to the file. Since every operation on a microVM node checks that its names are the ones under which Windows stores its entry (microsoft/nvx#1603), every operation on such a child failed with ENOENT, although the guest never chose the name. A volume that exposes a file reaches nothing else, so the guest names nothing in it, and only the host chose the name by which it reaches the file. The check of stored names now skips such a volume. OpenVMM's command line and NVX canonicalize a file child's path, which gives the stored names, so they were unaffected. Tests, in the aggregate tests on Windows: a file child attached by its file's name in another case, and, on a volume that generates 8.3 short names, by its short name, reads and writes the file. Without the fix, on Windows, reading the child fails with ENOENT; with it, the test and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On a strict volume on Windows, the check of a rename's names checked its target only when its source existed: without a source, it passed the rename on to the host, which fails it. But the guest's requests run concurrently, so the guest could create the source between the check and the host's rename, which then replaced whatever another name of the target reached, such as a denied file through its 8.3 short name (microsoft/nvx#1603): on the host, a replacing rename of staging onto CREDEN~1.JSO leaves credentials.json with the content of staging. The check now fails a rename without a source itself, with ENOENT, as the host would, so no rename reaches the host with its target unchecked. Whether a volume checks the names at all is now asked of checks_stored_names, rather than inferred from a missing stored path, which also stands for a missing entry. Tests, in the microVM policy tests on Windows: the check of a rename from a missing source, onto a denied file's short name or onto another name, fails with ENOENT. Without the fix, on Windows, it passes; with it, the test and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
added a commit
that referenced
this pull request
Nov 22, 2026
A handle map handed out u64::MAX as its last handle (microsoft/nvx#1627). An aggregate's synthetic root uses u64::MAX as its directory handle, SYNTHETIC_ROOT_FH, on the documented assumption that no real handle takes it, so a child's file or directory that got it shared its handle with the root: a RELEASE that names the root's node and handle, which a client sends for a file rather than a directory, closed the child's descriptor, since closing a handle does not check its node. A map that handed out u64::MAX also wrapped its next handle to 0, which a microVM save then recorded and every restore rejects as an invalid allocation state, so the VM could no longer be restored, for node IDs as for file handles. HandleMap::can_insert, which insert and reserve check, refused only a next handle of 0, the wrapped one. Live requests would take some 2^64 allocations to reach u64::MAX, but a microVM restore accepts any next handle or node ID above the saved ones, u64::MAX included, and the next OPEN, OPENDIR, or CREATE, or LOOKUP of a new object, then got u64::MAX. Refuse a next handle of u64::MAX too, so that a map whose next handle reaches it is full: the request that needs another handle or node fails with ENOSPC, as at any other exhaustion, and the map's next handle stays u64::MAX, which a save records and a restore accepts. No restored handle or node can hold u64::MAX, since a restore requires every saved ID below the next one, so the saved state and its schema are unchanged. handle_map_stops_after_max_handle now checks that a map hands out u64::MAX - 1 as its last handle and that a map that starts at u64::MAX, as a restored one can, is full; the reservation tests that started at the last handle start at u64::MAX - 1. In microvm::aggregate_fs_tests, children_never_get_the_synthetic_root_handle restores an aggregate whose next handle ID is u64::MAX and checks that OPEN, OPENDIR, and CREATE in a child fail with ENOSPC and leave the host unchanged, that the root's handle still lists the root, and that the state saves and restores again; in microvm::fs_tests, largest_restored_next_node_id_is_never_handed_out does the same for a LOOKUP with the largest next node ID. On 8225e2c, the head of #5224 (microsoft/nvx#1603), with the fix reverted, the HandleMap test gets u64::MAX, the aggregate test gets handle u64::MAX for the child's file, the node test gets node u64::MAX, and unused_reservations_release_on_drop reserves u64::MAX; a probe there also showed that the save that followed recorded a next handle ID of 0, which the restore rejected, and that a RELEASE of the root's handle closed the child's. With the fix, they and the rest of cargo nextest -p virtiofs pass on Windows and on a Linux KVM host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
READDIRPLUS reads a directory's entries from the snapshot that its first read takes, and the third commit had it look the listed names up without checking that each is the name under which Windows stores its entry, since the host had listed it. But a later read can list a name whose case has changed since the snapshot, which Windows still resolves to the entry (microsoft/nvx#1603). After a rename of new to NEW, the read handed the guest a node of new, whose every request then failed with ENOENT; and once the host had replaced old with another file named OLD, the read failed at old with EIO, since the name reached another object than the one listed, and so did every later read, which starts there. READDIRPLUS looks the names up with the checked lookup_child again, so such a name fails with ENOENT, and the read skips it, as it skips a name that is gone. The unchecked lookup_listed_child goes. On a Windows host, each listed entry costs another open, which queries its stored name. A Copilot review of microsoft/nvx#1963 found this. Tests, in the microVM policy tests on Windows: READDIRPLUS reads after the host renamed new to NEW and replaced old with OLD list none of them. Without the fix, on Windows, the reads fail with EIO; with it, the test and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 22, 2026
…dmap Map positions 358-363, the commits of microsoft/openvmm#5224, which NVX now pins at 7671411e8, 237 commits past the mapped tip: - 358, lxutil: report the names under which Windows stores an entry. LxVolume::stored_path returns the path under whose names Windows stores the entry that a path reaches. - 359, virtiofs: hide a microVM policy path in another case on Windows. The access policy also matches names ignoring case on Windows, only ever to restrict, including its check of the paths below a rename. - 360, virtiofs: reach a Windows entry only by its own name in a microVM. The guest reaches an existing entry only by the names that Windows stores for it, as on Linux, and a node fails once its names reach an entry by other names. - 361, virtiofs: let a Windows file child name its file by any of its names. A file child, whose host path the device keeps as given, is exempt from position 360's checks. - 362, virtiofs: fail a Windows rename without a source before the host. Position 360's check no longer passes a rename whose source is missing to the host with its target unchecked. - 363, virtiofs: skip a Windows READDIRPLUS name whose case has changed. READDIRPLUS checks the names that its snapshot lists again, which position 360 had it skip. Positions 358-363 are not yet assigned to a PR. The gap dates from the denied paths of PR22's position 102, but positions 358 and 359 change only upstream's code and what positions 160 and 357 add, and nothing that a mapped PR adds; position 360 also changes what PR18's position 081 and its fixups at positions 345 and 351 add, so assigning it revisits PR18; and positions 361-363 fix position 360. Upstream main, bf353460f, lacks the defect, since it lacks the access policy, and each commit conflicts there, so none can go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 22, 2026
Pedro Henrique Penna (ppenna)
merged commit Nov 22, 2026
7671411
into
feature/microvm/dev
103 of 104 checks passed
5 tasks done
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 22, 2026
OpenVMM's virtio-fs server handed out u64::MAX as the last ID of a handle or node table, though an aggregate's synthetic root answers OPENDIR with that handle, and then wrapped the table's next ID to 0 (#1627). A microVM restore accepts a saved next handle or node ID of u64::MAX, so the next OPEN, OPENDIR, or CREATE, or LOOKUP of a new object, got u64::MAX: a child's file then shared the root's handle, so that a RELEASE of the root's handle closed it, and the next save recorded a next ID of 0, which every restore refuses, so the VM could no longer be restored. Pin microsoft/openvmm 78ddb8044c15e8d45276c902d31b6465e1bcbf6c, two commits on 7671411e8, the head of feature/microvm/dev, where microsoft/openvmm#5224 landed: - virtiofs: never hand out u64::MAX, the synthetic root's handle. A table whose next handle or node ID reaches u64::MAX is full: the request that needs another one fails with ENOSPC, and the next ID stays u64::MAX, which a save records and a restore accepts. - virtiofs: restart a restored microVM's handles at 1 on a reset. A reset or FUSE_DESTROY numbered a restored filesystem's handles from the saved next ID again, so that a table restored full stayed full after the guest remounted; they now restart at 1, as a new filesystem's do. Their tests fail without the changes on Windows and on Linux (nvx-kvm-test). No saved state, protocol, ABI, or format, and no version of any of them, changes. The protocol vectors and CPU profiles that nvx copies are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 22, 2026
Map positions 364 and 365, the commits of microsoft/openvmm#5225, which NVX now pins at 78ddb8044, 239 commits past the mapped tip, and name 7671411e8 as the head of feature/microvm/dev, where microsoft/openvmm#5218 through microsoft/openvmm#5224 have landed: - 364, virtiofs: never hand out u64::MAX, the synthetic root's handle. HandleMap::can_insert refuses a next handle of u64::MAX, so that a handle or node table is full there rather than hand out the synthetic root's directory handle and wrap its next ID to 0, which a microVM restore refuses. - 365, virtiofs: restart a restored microVM's handles at 1 on a reset. The restore of a microVM's handle table keeps a new table's first handle, so that a reset or FUSE_DESTROY that ends the guest's session numbers the handles from 1 again rather than from the saved next ID, at which a table that position 364 leaves full stayed full. Position 364 is not yet assigned to a PR: it changes upstream's can_insert and the comment on SYNTHETIC_ROOT_FH, whose first lines position 356 changes, and nothing that a mapped PR adds, and it fixes no defect of PR18's position 083, whose restore only makes upstream's defect reachable. Position 365 changes the line of restore_microvm_state that position 083 adds and fixes its defect, so it is a PR18 fixup: fold it into position 083, and its test into position 364, whose full table the test restores and resets. Upstream main, bf353460f, has the defect of position 364 but no restore that reaches it; replaying position 364 there conflicts in aggregate.rs and in the microVM's tests, which upstream main lacks, while its change to lib.rs applies, and replaying position 365 conflicts in the microVM's fs.rs and fs_tests.rs, which upstream main lacks, so it follows PR18 upstream. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Gautam Ahuja (ahuja-gautam)
pushed a commit
to ahuja-gautam/openvmm
that referenced
this pull request
Nov 22, 2026
A handle map handed out u64::MAX as its last handle (microsoft/nvx#1627). An aggregate's synthetic root uses u64::MAX as its directory handle, SYNTHETIC_ROOT_FH, on the documented assumption that no real handle takes it, so a child's file or directory that got it shared its handle with the root: a RELEASE that names the root's node and handle, which a client sends for a file rather than a directory, closed the child's descriptor, since closing a handle does not check its node. A map that handed out u64::MAX also wrapped its next handle to 0, which a microVM save then recorded and every restore rejects as an invalid allocation state, so the VM could no longer be restored, for node IDs as for file handles. HandleMap::can_insert, which insert and reserve check, refused only a next handle of 0, the wrapped one. Live requests would take some 2^64 allocations to reach u64::MAX, but a microVM restore accepts any next handle or node ID above the saved ones, u64::MAX included, and the next OPEN, OPENDIR, or CREATE, or LOOKUP of a new object, then got u64::MAX. Refuse a next handle of u64::MAX too, so that a map whose next handle reaches it is full: the request that needs another handle or node fails with ENOSPC, as at any other exhaustion, and the map's next handle stays u64::MAX, which a save records and a restore accepts. No restored handle or node can hold u64::MAX, since a restore requires every saved ID below the next one, so the saved state and its schema are unchanged. handle_map_stops_after_max_handle now checks that a map hands out u64::MAX - 1 as its last handle and that a map that starts at u64::MAX, as a restored one can, is full; the reservation tests that started at the last handle start at u64::MAX - 1. In microvm::aggregate_fs_tests, children_never_get_the_synthetic_root_handle restores an aggregate whose next handle ID is u64::MAX and checks that OPEN, OPENDIR, and CREATE in a child fail with ENOSPC and leave the host unchanged, that the root's handle still lists the root, and that the state saves and restores again; in microvm::fs_tests, largest_restored_next_node_id_is_never_handed_out does the same for a LOOKUP with the largest next node ID. On 7671411, where microsoft#5224 (microsoft/nvx#1603) landed, with the fix reverted, the HandleMap test gets u64::MAX, the aggregate test gets handle u64::MAX for the child's file, the node test gets node u64::MAX, and unused_reservations_release_on_drop reserves u64::MAX; a probe there also showed that the save that followed recorded a next handle ID of 0, which the restore rejected, and that a RELEASE of the root's handle closed the child's. With the fix, they and the rest of cargo nextest -p virtiofs pass on Windows and on a Linux KVM host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Refs microsoft/nvx#1603.
Stacked on #5223 (microsoft/nvx#1601): only the top 6 commits,
e69b05c9c,fced96721,e82e57fba,f1d11fa84,8225e2cfb, and7671411e8, belong to this PR. NVX pins the head of this branch, so this is a prerequisite of the NVX change that pins it, and it lands after #5223 by fast-forwardingfeature/microvm/devto that exact commit, not with the merge button, which squashes.What and why
On a Windows host, a microVM share's access policy (
SubtreePolicy, with its denied, allowed, and writable paths) compared the guest's names byte for byte, while Windows resolves a name in another case to the entry of that name, unless the directory is case sensitive, and also resolves the 8.3 short name of a long name, such asCREDEN~1.JSOforcredentials.json. A name that the policy did not recognize therefore reached an entry that it protects. On a read-write share withdenied_paths = ["marker"]or["credentials.json"], the guest could:FUSE_UNLINK,FUSE_RENAMEof, orFUSE_RENAMEontoMARKERorCREDEN~1.JSO;logsunder--mount-allow logs/payloads, to a visible name withFUSE_RENAMEofLOGS, exposing its hidden entries;--mount-deny logs/secret, renameLOGSpast [DO NOT REVIEW] virtiofs: refuse renames of directories that hold denied paths #5223's check that no denied path lies below a rename's names, moving the hiddensecretwith it, and once the host had movedlogsaway, rename a directory of its own ontoLOGS, putting its entries at the denied path;CREDEN~1.JSO, or plant a file of its own at the denied path withFUSE_CREATEofMARKERwhile it was gone;EACCESagainstENOENT;OUTas a name of the writable directoryout, after which no write intooutpassed the policy.The pinned identities that the share records when it attaches stop none of these: they reject only objects that existed then, and only when a lookup reaches them.
The fix
lxutil: report the names under which Windows stores an entryaddsLxVolume::stored_pathon Windows. It opens the entry that a path reaches without access, exactly as every other operation resolves the path, and queriesFileNormalizedNameInformation, whose final components are the stored long names of the path's components.virtiofs: hide a microVM policy path in another case on Windows: on Windows,SubtreePolicy::visibility, and with itis_writable,is_subtree_writable([DO NOT REVIEW] virtiofs: refuse renames of directories that hold denied paths #5223's check of the paths below a rename), and every check ofVirtioFsVolume, also matches the policy's paths ignoring case and keeps the more restrictive result. A name of a denied path in another case is hidden as the path is, and one of a traverse-only directory is traverse-only, but another case never exposes an allowed path or makes a writable path writable. Names match ignoring case when Unicode's full upper-case mappings agree, a superset of a Windows upcase table's equality that is used only to restrict. Policy validation and the pinned identities still compare the canonical paths exactly, and Linux keeps exact matching.virtiofs: reach a Windows entry only by its own name in a microVM: on a strict volume on Windows, the guest reaches an existing entry only by the names that Windows stores for it, as on Linux. A lookup, unlink, rmdir, or rename source by another name of an entry fails withENOENT, as for a missing name; a create withoutO_EXCL, which would open the entry, and a rename target, which it would replace, fail withEACCES; a rename of an entry to its own name in another case changes that name's case. Every path-based operation on a node also checks the node's names first, so a node whose name later reaches another entry, as when the host recreates a denied file whose short name matches a name the guest once used, fails withENOENT. READDIRPLUS looks up the names that the host lists, which are the entries' own, and revalidates their identities, so it needs no check.virtiofs: let a Windows file child name its file by any of its names: an aggregate's file child reaches its file by the last name of its host path, which the device keeps as given (openvmm: virtiofs: microVM aggregate file child accepts bare relative paths and symlinks in identity validation but fails in open_microvm_volume nvx#1618), and which may be the file's name in another case or its short name. The guest names nothing in a volume that exposes a file, which reaches nothing else, so the third commit's check skips such a volume, which it otherwise made fail every operation on the child withENOENT. OpenVMM's command line and NVX canonicalize a file child's path, so they were unaffected.virtiofs: fail a Windows rename without a source before the host: the third commit's check of a rename passed a rename whose source was missing to the host without checking its target, but the guest's requests run concurrently, so it could create the source in between, and the host's rename would then replace whatever another name of the target reached: on the host, a replacing rename ofstagingontoCREDEN~1.JSOleavescredentials.jsonwith the content ofstaging. The check now fails such a rename withENOENTitself, as the host would. A code review of the rebased branch found this.virtiofs: skip a Windows READDIRPLUS name whose case has changed: READDIRPLUS reads a directory's entries from the snapshot that its first read takes, so the third commit's unchecked lookup of the listed names,lookup_listed_child, returned a later page's name whose case had changed since: after a rename ofnewtoNEW, the guest got a node ofnewwhose every request failed withENOENT, and once the host had replacedoldwith a file namedOLD, the read failed atoldwithEIO, as did every later read. READDIRPLUS looks its names up with the checkedlookup_childagain, so it skips such a name, as it skips one that is gone;lookup_listed_childgoes. On a Windows host, each listed entry costs another open. A Copilot review of openvmm: pin the Windows name checks of microVM shares nvx#1963 found this.No saved state, protocol, ABI, or format, and no version of any of them, changes. Linux hosts behave as before. The Guide's access-policy and security-model sections describe the Windows behavior.
Kept from the issue's suggested fix: Windows itself supplies the names that it stores for an entry, from
FileNormalizedNameInformation, and a request whose spelling differs from them fails (its first option). Changed: the names come from a zero-access open that resolves the path exactly as the operation does, just before it, rather than from the operation's own handle, since without the host's help the guest cannot change what a name reaches in between; a node's own names are checked too; and on Windows the policy also matches names ignoring case, only ever to restrict, which covers a name in another case that reaches no entry yet, such asMARKERonce the host has removedmarker, which no open can normalize.OBJ_CASE_INSENSITIVEstays, since exact names make the case in which an open resolves a name irrelevant for an existing entry, and the policy restricts every name in another case.Residual limits, which the issue does not cover: an exclusive create,
mkdir,mknod,symlink, orlinkunder another name of an existing entry fails withEEXIST, as Windows refuses it, so it still tells that some entry has that short name; and on a volume that generates 8.3 names, a denied path that is itself named like a short name (ABCDEF~1.EXT) can become the short name of a guest file once the host removes it. A file whose ACL denies the VMMSYNCHRONIZE, which every other operation on it already needs, can no longer be looked up.Tests
All in
cargo nextest run --profile agent -p lxutil -p virtiofs; thelxutiltest and the nine microVM tests run only on Windows.lxutiltests::stored_path_has_the_names_that_the_file_system_stores: a path reaches its entry's stored names through a name in another case and through a hard link's own name, a missing entry or ancestor yieldsNone, and on a volume that generates 8.3 short names, a short name in either case yields the long name.microvm::policy::tests::names_in_another_case_only_restrict_paths_on_hosts_that_ignore_case: both name matchings ofvisibility_on,is_writable_on, andis_subtree_writable_on, including non-ASCII letters, a denied and an allowed path that differ only in case, and a denied path below a name in another case.microvm::policy_tests::a_denied_path_in_another_case_is_hidden:FUSE_UNLINK,FUSE_RENAMEof and onto,FUSE_CREATE, andFUSE_LOOKUPof a denied file in another case fail as with its own name.microvm::policy_tests::a_recreated_denied_path_stays_hidden_in_another_case: once the host removes the denied file, the guest can neither create, make, nor link it in another case, nor look it up or probe it with an exclusive create, and once the host recreates it, neither reach nor replace it.microvm::policy_tests::a_traverse_only_directory_in_another_case_stays_in_place: a traverse-only directory in another case, at the root or inside a writable path, can be neither renamed nor removed.microvm::policy_tests::renames_never_move_a_denied_path_in_another_case: withlogs/secretdenied, renamingLOGSfails withEROFS, and once the host has movedlogsaway, so does renaming the guest'sstaging, which holds asecret, ontoLOGS.microvm::policy_tests::the_guest_reaches_entries_only_by_their_own_names: names in another case reach no entry, neither remove, move, nor replace one, and no longer make a writable directory read-only, while a rename to an entry's own name in another case renames it.microvm::policy_tests::short_names_reach_no_entry: a short name of a denied or a visible file reaches no entry, before and after the host recreates the denied file, and a node whose name became the recreated file's short name can neither open nor inspect it.microvm::aggregate_fs_tests::a_file_child_may_name_its_file_by_another_of_its_names: a file child attached by its file's name in another case, and by its short name, reads and writes the file.microvm::policy_tests::readdirplus_skips_names_whose_case_changed_since_its_snapshot: after the first READDIRPLUS read of a directory, the host renamesnewtoNEWand replacesoldwithOLD, and the later reads list neither.microvm::policy_tests::a_rename_without_a_source_fails_before_its_target_is_reached: the check of a rename from a missing source, onto a denied file's short name or onto another name, fails withENOENT; a race cannot be reproduced deterministically, so the test checks the rename check itself.Validation
cargo nextest run --profile agent -p lxutil -p virtiofs, with the fixes reverted and with them:49fc14eebe69b05c9candfced96721FUSE_UNLINKofMARKERand ofCREDEN~1.JSOdelete the denied files,FUSE_CREATEofMARKERplants a file at the denied path,FUSE_RENAMEofLOGSmoves both the traverse-onlylogsand thelogsthat holdslogs/secret(left: Ok(()),right: Err(EROFS)), andFUSE_LOOKUPofOUTsucceedsFUSE_LOOKUPofOUTandFUSE_UNLINKofCREDEN~1.JSOsucceede82e57fba, 290 at this headnvx-kvm-test, Azure Linux 3.0 VMe82e57fbaand at this headMutations at this head, on Windows:
is_subtree_writableexactly again: the unit test fails atLOGS, and so doesrenames_never_move_a_denied_path_in_another_case. Without its first rename, it fails at the second: renamingstagingontoLOGSafter the host movedlogsaway returnsOk(())and puts the guest'ssecretat the denied path, which exact names do not stop, sinceLOGSthen reaches no entry.validate_confined_paths:short_names_reach_no_entryfails, as the guest's node of its removedCREDEN~1.JSOopens the recreated denied file.e82e57fba, without the fourth commit:a_file_child_may_name_its_file_by_another_of_its_namesfails, as reading the child attached asLONG-FILE-NAME.TXTfails withENOENT.a_rename_without_a_source_fails_before_its_target_is_reachedfails withleft: Ok(()),right: Err(ENOENT).readdirplus_skips_names_whose_case_changed_since_its_snapshotfails, as a later read fails withEIO; with only the rename, it listsnew(left: ["a", "new", "z"]).At
e82e57fba, on both hosts,cargo check,cargo clippy --all-targets, andcargo doc --no-depswithRUSTDOCFLAGS=-D warningsforlxutilandvirtiofsare clean, with no warning but theLNK4199linker message that every linked artifact gets on the Windows machine, and only the base's ignored tests are skipped: five on Windows, four on Linux. The Windows tests ran on a volume that generates 8.3 short names, so the short-name tests did not skip.git rebase --exec "cargo check -q -p lxutil -p virtiofs --tests" 49fc14eebpasses for each commit, andcargo xtask fmt --fixchanges nothing. At this head, on Windows, the package tests pass,cargo clippy --all-targetsandcargo doc --no-depsare clean, andcargo xtask fmt --fixchanges nothing; on nvx-kvm-test,cargo clippy --all-targetsis clean and 269 tests pass, 4 skipped, as ate82e57fba, wherecargo check --all-targetsandcargo doc --no-depswere clean too. NVX's microVM filesystem scenarios also pass with OpenVMM built from this head, on KVM (nvx-kvm-test) and on WHP (nvx-whp-test).