Repository navigation
[DO NOT REVIEW] virtiofs: leave entries that lookups refuse out of microVM listings - #5289
Merged
Pedro Henrique Penna (ppenna) merged 9 commits intoNov 26, 2026
Conversation
A microVM MKDIR, MKNOD, SYMLINK, or CREATE that reserved the last node ID that the node table hands out, u64::MAX - 1, made its object on the host and then failed with ENOSPC (microsoft/nvx#2135). The guest saw the request fail while the object stayed on the host, and every retry under another name left another object behind. A restore reaches that state, since it accepts any next node ID above the saved ones; live requests would need some 2^64 allocations. These requests reserve the node ID of their object before they make it, so that a full table refuses them before the host changes, and insert the object's node with that ID afterwards. InodeReservation::insert checked that insert against the microVM limits with InodeMap::preflight_microvm_insert, which, for a node of its own, also requires that the table can hand out its next node ID. The reservation has already taken that ID, so the check asked about the ID after it: after a reservation of u64::MAX - 1, the table's next node ID is u64::MAX, which it never hands out, and the insert failed although it needed no other ID. The check dates from the microVM profile (dbf0fa4); before 3019375 made u64::MAX - 1 the last node ID, it failed this way after a reservation of u64::MAX. FileReservation::insert checks only the handle limit, so handles are not affected. Check a reserved insert with the new InodeMap::preflight_microvm_reserved_insert, which checks the inode and alias limits as before but not the next node ID. The checks that run before the host changes, and inserts without a reservation, such as a LOOKUP's, are unchanged. microvm::fs_tests::a_created_object_takes_the_last_node_id restores a state whose next node ID is u64::MAX - 1 and checks, for each of the four requests, that the request returns node u64::MAX - 1, which a LOOKUP of the new name returns too, that the next such request fails with ENOSPC and leaves nothing on the host, and that the state then saves the node and the next node ID u64::MAX, and restores. On 1633b37, MKDIR fails the test with ENOSPC; a probe there showed each of the four requests failing with ENOSPC twice in a row, each time leaving its object on the host, and the state saving no node, on Windows and on a Linux KVM host. With the fix, the test and the rest of cargo nextest -p virtiofs pass on both. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM guest that opened a virtio-fs file with access mode 3 and held it open could save the VM's state, but its restore failed with "saved handle has invalid access mode", on read-write and read-only shares alike (microsoft/nvx#2125). Linux's open(2) reserves access mode 3 to check for read and write permission and return a descriptor that can neither read nor write, and the guest's FUSE client sends that access mode to FUSE_OPEN, which accepts it. The restore disagreed with FUSE_OPEN about such a handle twice. reopen_flags rejected access mode 3 outright, and validate_microvm_state took every access mode other than O_RDONLY for one that writes, so a read-only share or child, or a node outside the writable paths, could not restore the handle even without that rejection. FUSE_OPEN gives the handle there, since check_open_readonly refuses only the opens that opens_for_writing names: those for O_WRONLY or O_RDWR, or with O_TRUNC. reopen_flags now keeps every access mode, and the validation takes a handle for one that writes as opens_for_writing takes the open that reopens it, which drops O_TRUNC, so only O_WRONLY and O_RDWR need a writable node. A restored handle keeps access mode 3, so it still neither reads nor writes. The format of the saved state is unchanged. a_handle_that_neither_reads_nor_writes_survives_save_and_restore opens a file with access mode 3 on a read-write share, on a read-only share, and outside the writable paths of a read-write share, saves and restores the state, and expects the restored handle to serve its node and to fail reads and writes with EBADF. At feature/microvm/dev 1633b37, the restore fails with "saved handle has invalid access mode" on Windows 11 (NTFS) and Azure Linux 3 (kernel 6.18, tmpfs). Without that check alone, it fails with "read-only microVM profile cannot restore a writable handle" on the read-only share, and with "microVM access policy cannot restore a writable handle outside its writable paths" outside the writable paths. With the fix, the test passes on both hosts, and so do the other tests of the virtiofs package. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On Windows, lxutil stores a Linux xattr as an NTFS extended attribute named `LX.` and the xattr's name. FILE_GET_EA_INFORMATION and FILE_FULL_EA_INFORMATION give that EA name's length in one byte, but lxutil's limit on xattr names, LX_UTIL_XATTR_NAME_MAX, was u16::MAX - 3 bytes, and lxutil wrote the length with `as u8`, which kept only its low 8 bits (microsoft/nvx#2137). A FUSE_GETXATTR of a 262-byte name that starts with `user.a`, which a guest can send by building the request itself, thus queried the 9-byte EA name `LX.user.a`, 265 bytes modulo 256, and returned the value of the `user.a` attribute. Names of 252 to 261 bytes failed with EINVAL or ENODATA, depending on the operation and the length, rather than with ERANGE, and XATTR_CREATE of the 262-byte name failed with EEXIST. NTFS accepts EA names of at most 254 bytes, so lxutil can store xattr names of at most 251 bytes. LX_UTIL_XATTR_NAME_MAX is now that length. set_name, like get and set, accepts a name of exactly that length rather than rejecting it with `>=`, and returns the EA name's length as the u8 that the headers hold. get, set, and remove thus fail every longer name with ERANGE before it reaches NTFS, as Linux fails names longer than its 255 bytes. The documentation of LxVolume's xattr methods now gives the limit. xattr_name_length sets `user.a`; sets, reads, and removes an attribute whose name has the longest length that the platform allows, 251 bytes on Windows and 255 on Linux; expects every longer name, up to 262 bytes, to fail with ERANGE in get, get of the size, set with no flag, with XATTR_CREATE, and with XATTR_REPLACE, and remove; and expects `user.a` to keep its value. At feature/microvm/dev 1633b37, it fails on Windows 11 Enterprise (build 26300, NTFS) at the first longer name, whose get failed with EINVAL. A one-off test there, not committed, showed the rest: every operation on a 252- or 253-byte name failed with EINVAL; on 254- to 261-byte names, get, XATTR_REPLACE, and remove failed with ENODATA, and set and XATTR_CREATE with EINVAL; and the 262-byte name read `secret`, the value of `user.a`, failed XATTR_CREATE with EEXIST, and failed set, XATTR_REPLACE, and remove with EINVAL. With the fix, the lxutil tests pass on Windows 11 and on Azure Linux 3 (kernel 6.18, ext4). Linux builds do not compile xattr.rs, so the fix leaves Linux's behavior as it was. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On Windows, LxVolume::symlink and symlink_stat accepted an empty target (microsoft/nvx#2126), which Linux's symlink(2) fails with ENOENT. On a volume that does not confine paths, the empty target names the link's own directory, so symlink_helper chose an NT directory link and called create_nt_link_reparse_buffer. That sized its buffer as the REPARSE_DATA_BUFFER up to the PathBuffer of its symbolic link part, 20 bytes, plus the target twice, but wrote the whole 24-byte struct at its start: with an empty target, 4 bytes past the end of the heap allocation. Where the process may not create NT links, setting that reparse point then failed, and the volume fell back to a WSL-style link to the empty target, as a volume that confines paths makes directly. A virtio-fs guest could thus overflow the host's heap and get a symbolic link to nothing on a direct share, and a virtio-9p guest the same, since both devices pass the guest's target to the volume unchanged. A microVM share already refused an empty target itself. symlink_helper now fails an empty target with ENOENT before it checks the link's path or creates anything, as symlink(2) does, and create_nt_link_reparse_buffer, whose write of the struct relies on a target that is not empty, refuses an empty one with ENOENT too, so that the write stays within the buffer whatever its caller passes. symlink_rejects_an_empty_target checks that symlink and symlink_stat fail with ENOENT and leave no link, with and without confine_paths; nt_link_reparse_buffer_refuses_an_empty_target checks the guard of create_nt_link_reparse_buffer; and virtiofs's direct_symlink_rejects_an_empty_target checks that a guest SYMLINK with an empty target on a direct share fails with ENOENT and leaves no link on the host. At feature/microvm/dev 1633b37, on Windows 11 (NTFS, a process that may not create NT links), all three fail: the first and the last create a symbolic link to the empty target, and the second gets a 20-byte buffer. An AddressSanitizer build of the first, with windows_hook_rtl_allocators, reports a heap-buffer-overflow there: a 24-byte write 0 bytes after a 20-byte region, in create_nt_link_reparse_buffer. With the fix, the three pass, and so do lxutil's other tests, also under AddressSanitizer. On Linux, whose kernel refuses an empty target, and where none of the changed code builds, the first and the last pass with and without the fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM guest that holds a file on a virtio-fs share open with O_DIRECT could save the VM's state, but not restore it: restore_microvm_state refused the saved handle with "saved handle has unsupported open flags 0x4002" for O_RDWR | O_DIRECT, and with 0x4041 for a file that FUSE_CREATE created with O_WRONLY | O_DIRECT (microsoft/nvx#2128). The Linux FUSE client passes the open's O_DIRECT in the flags of both requests. FUSE_OPEN and FUSE_CREATE accept O_DIRECT, keep it in the flags that the handle records, which the save stores, and pass it to the host open: Linux opens the host file with it, and Windows ignores it. reopen_flags, which validates a saved handle's flags before a restore and gives those with which the restore reopens it, refused any flag outside its list, which lacked O_DIRECT. It now keeps O_DIRECT, so that a restore reopens the handle as the guest opened it, and the handle keeps the host's O_DIRECT semantics: on a Linux filesystem that enforces O_DIRECT's alignment, such as ext4, the restored handle performs block-aligned I/O and refuses unaligned I/O with EINVAL, as the saved one did, where a handle reopened without O_DIRECT would have accepted both. handles_opened_with_o_direct_restore_with_it first checks that reopen_flags keeps O_DIRECT and the access of the flags that FUSE_OPEN and FUSE_CREATE record, and drops O_CREAT. It then opens a file with FUSE_OPEN and O_RDWR | O_DIRECT, creates one with FUSE_CREATE and O_WRONLY | O_CREAT | O_DIRECT, saves the state, restores it into a new attachment, and expects each handle to be reopened with O_DIRECT and its access. Linux lets a filesystem refuse O_DIRECT, as tmpfs did before Linux 6.6, so on Linux the test skips that round trip when the host refuses an open of the file with O_DIRECT that it tries outside the server; on Windows, which ignores O_DIRECT, it always runs it. At feature/microvm/dev 1633b37, the test fails at its first check, since reopen_flags refuses 0x4002, and without that check, its round trip fails at the restore, with 0x4002 on Windows 11 Enterprise (NTFS) and 0x4041 on Azure Linux 3 (kernel 6.18, x86_64, ext4), whichever handle the restore checks first. With the fix, it passes on both without skipping, as do the other tests of the virtiofs package. On the Linux host's ext4, a one-off test, not committed, read and wrote 4 KiB at offset 0 and 512 bytes at offset 512 through the O_DIRECT handle and failed reads and writes of 100 bytes at offsets 0 and 1 with EINVAL; after the restore, the handle still read 4 KiB at offset 0 and failed a read of 100 bytes at offset 1 with EINVAL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On a Windows host, LxVolume::link and LxVolume::link_stat failed with EOVERFLOW, and created no link, when the new name was one UTF-16 unit long, such as `x`, although longer names worked (microsoft/nvx#2136). A guest's `ln file x` on a virtio-fs share of a Windows directory thus failed, and so would one on a Plan 9 share, which links through the same LxVolume::link. create_link passes NtSetInformationFile a FILE_LINK_INFORMATION built from a header that mirrors the structure up to FileName, 20 bytes with an alignment of 1, followed by the name. NtSetInformationFile refuses a buffer shorter than sizeof(FILE_LINK_INFORMATION), which counts the first FileName unit and the trailing padding, 24 bytes on 64-bit Windows, with STATUS_INFO_LENGTH_MISMATCH, which lxutil maps to EOVERFLOW. A name of one unit made a buffer of 22 bytes. rename does not fail this way: its header starts with the 4-byte union of FILE_RENAME_INFORMATION, so its buffer rounds up to 24 bytes. create_link now pads the name with NULs until the buffer is as long as the structure, as pal's hard_link_relative already sizes its own. FileNameLength still counts only the name, so the link gets exactly that name. link_to_a_one_character_name links a file to `a` through link and to `b` through link_stat, and expects both names to reach the file, with link counts of 2 and 3. Without the fix, its first link fails with EOVERFLOW on Windows 11 Enterprise (build 26300, NTFS); with it, the test passes there, as do the other tests of the lxutil and virtiofs packages. A one-off test, not committed, of the issue's reproduction, a FUSE_LINK through VirtioFs of a file to `xy` and then to `x`, with the standard and the microVM profile, got EOVERFLOW for `x`, and left no host file, at feature/microvm/dev 1633b37, and a link count of 3 with the fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A guest could panic the VMM on a Windows host with one FUSE_READDIR or FUSE_READDIRPLUS of a virtio-fs share that VirtioFs::new serves, at an offset of 2^63 or more (microsoft/nvx#2127). virtio-fs, like Plan 9, passes the guest's unsigned offset to LxFile as an lx::off_t, so such an offset arrives negative. On Windows, LxFile::read_dir lists `.` and `..` at the offsets 0 and 1 and otherwise asserts that the offset is at least 2, which a negative one fails, and OpenVMM aborts on a panic. MicroVM shares list a directory from their own snapshot, whose cookies refuse such an offset already. A FUSE_WRITE at such an offset reached NtWriteFile as it was, on every share, microVM ones included. NtWriteFile takes the offset -1, from 2^64 - 1, for FILE_WRITE_TO_END_OF_FILE and -2, from 2^64 - 2, for FILE_USE_FILE_POINTER_POSITION, so those writes appended to the file or wrote at the handle's file pointer, where Linux fails a write at a negative offset with EINVAL. LxFile::pread already refused negative offsets. LxFile::read_dir and LxFile::pwrite now fail a negative offset with EINVAL on Windows before they do anything else, as Linux fails a seek of a directory to a negative offset, and a write at one before it clears set-user-ID and set-group-ID. read_dir_refuses_negative_offsets, on Windows, expects reads of a directory at -1 and at lx::off_t::MIN to fail with EINVAL without an entry. pwrite_refuses_negative_offsets, on every host, expects writes at -1, -2, and lx::off_t::MIN to fail with EINVAL and leave the file as it was. At feature/microvm/dev 1633b37, on Windows 11, the first fails the assertion, and the second appends at -1. With the fix, both pass, as do the other tests of lxutil, virtiofs, and plan9. At 1633b37, a one-off test, not committed, of virtio-fs on Windows panics at a FUSE_READDIR at 2^63, and FUSE_WRITEs of "X" to a file that holds "x" at 2^64 - 1 and 2^64 - 2 leave "xX" and "X", through a VirtioFs::new share and a microVM one alike; one at 2^63 fails with EINVAL. With the fix, FUSE_READDIR and FUSE_READDIRPLUS at 2^63 and 2^64 - 1, and the three writes, fail with EINVAL and leave the file as it was. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM snapshot that held a handle that FUSE_CREATE returned could fail to restore (microsoft/nvx#2129): the save succeeded, but the restore refused the handle with "saved handle has unsupported open flags". FUSE_OPEN records the options that util::open_flags derives from the guest's flags, without __FMODE_EXEC, O_LARGEFILE, and O_NOFOLLOW, which only the guest uses. FUSE_CREATE opened the file with the options that util::create_flags derives in the same way, but recorded the guest's flags as they came. A save stores the recorded flags, and a restore checks them with reopen_flags, which refuses __FMODE_EXEC and spells O_LARGEFILE as x86's 0x8000. On an x86-64 host, a create handle whose flags held __FMODE_EXEC, which only a guest that drives the queue itself sends with FUSE_CREATE, thus could not restore, and on an AArch64 host, where O_LARGEFILE is 0x20000 and 0x8000 is O_NOFOLLOW, no create handle of a 64-bit Linux guest could, since its kernel adds O_LARGEFILE to every open. Both date from 6315c16 (virtiofs: persist microVM FUSE namespaces, handles, and directory cookies). create now records the options, as open does, so a save stores no guest-only flag, and VirtioFsFile says that the flags that it records are such options. reopen_flags accepts lx::O_LARGEFILE, the host architecture's value, in place of x86's, because a snapshot from a release that recorded the guest's flags holds O_LARGEFILE in each of its create handles; the restore drops it, as it drops O_NOFOLLOW. A create handle of such a snapshot that holds __FMODE_EXEC still fails to restore. No saved-state format or version changes. a_create_handle_saves_and_restores_without_guest_only_flags, in the microVM's persistence tests, creates a file on a read-write share with O_RDWR | O_CREAT and the three guest-only flags, saves, restores, checks that the handle saved O_RDWR | O_CREAT, and writes and reads the file through the restored handle; then again with the saved handle holding O_LARGEFILE and O_NOFOLLOW too, as such a release saved it. Without the fix, at 4aeb405 as at feature/microvm/dev 1633b37, the restore fails on Windows 11 and on Linux (x86-64) with "saved handle has unsupported open flags 0x28062". With the fix, the test and the package's other tests pass on both. The second case fails without the change to reopen_flags only where O_LARGEFILE is not 0x8000, as on AArch64, which no host here runs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM guest could not list a host directory that held a single entry whose name or path every lookup refuses (microsoft/nvx#2133). The first read of a directory handle lists the directory into a snapshot, from which every later read pages. The listing left out the entries whose paths the access policy hides, for which child_path fails with EACCES, but failed for any other refusal of child_path: EINVAL for a name that the share refuses, such as one that holds `:` or `\`, which a Windows host also lists for the private-use characters that stand for them, and E2BIG for a path longer than MAX_PATH_BYTES, as the paths of a directory's entries become when the guest renames an ancestor to a longer name. It also failed with EINVAL for a name longer than 255 bytes, as a Windows name of fewer UTF-16 code units can be, although no FUSE request carries such a name. Every read of the directory then failed, so the guest could list none of its entries, not even those that it could look up. The listing now leaves such entries out, as it leaves out the hidden ones: those whose names fuse::check_name refuses, as the parser of every FUSE request does, and those for which child_path fails with EACCES, EINVAL, or E2BIG, as it does for a lookup. These entries count toward neither bound of a listing. The listing no longer checks the length of the names that it holds itself, since check_name bounds them by NAME_MAX, 255 bytes, the bound of a saved listing's names, which validate_directory_entries still checks. READDIRPLUS looks up each entry of a listing, which a handle may have taken before such a rename, and failed at an entry whose path the rename made longer than MAX_PATH_BYTES, and with it every later read, since each starts at that entry. It now skips the entry, as one whose name is gone, since a new listing would leave it out. Only the lookup fails with E2BIG for such a path: the E2BIG with which insert_lookup refuses a node once the nodes hold 1 MiB of names still fails the read, since the guest can reach the entry once it forgets other nodes. Tests in microvm/fs_tests.rs: - microvm_listings_leave_out_names_that_the_share_refuses lists a share that holds names with `:` and `\`, and, on Windows, with the private-use characters that stand for them and for NUL; - microvm_listings_leave_out_entries_whose_paths_exceed_the_bound lists a directory whose ancestor the guest renamed until one entry's path exceeds MAX_PATH_BYTES, through a new handle and through READDIRPLUS of the listing taken before the rename; - microvm_listings_leave_out_names_longer_than_a_request_carries, on Windows, lists a share that holds a name of 300 bytes; - readdirplus_fails_at_an_entry_whose_node_exceeds_the_bound_on_names checks that READDIRPLUS still fails with E2BIG at an entry whose node the bound on the nodes' names refuses. At feature/microvm/dev 1633b37, the first three fail at the listing, with EINVAL, E2BIG, and EINVAL, on Windows 11 (NTFS), and the first two do on Azure Linux 3 (kernel 6.18, tmpfs); with only the listing's part of the fix, READDIRPLUS of the earlier listing still fails with E2BIG. The fourth passes there, and fails if READDIRPLUS skips every E2BIG. With the fix, the virtiofs tests pass on both hosts. 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 25, 2026 17:51
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
This was referenced Nov 25, 2026
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 25, 2026
A microVM guest could not list a host directory that held a single entry whose name or path every lookup refuses (#2133): a guest's busybox ls -a of such a share printed no name. The listing that the first read of a directory handle takes left out the entries that the access policy hides, but failed for a name that the share refuses, such as one that holds a colon or a backslash, for a path longer than 4,096 bytes, as a rename of an ancestor can make an entry's path, and for a name longer than 255 bytes, which no FUSE request carries, so that every read of the directory failed. Pin microsoft/openvmm a79b4bb40da0662a873798a094209cc9be59eb32, the head of microsoft/openvmm#5289, one commit on 1495ac815, the head of microsoft/openvmm#5288, which NVX pins below this commit: - virtiofs: leave entries that lookups refuse out of microVM listings. The listing leaves out the entries whose names fuse::check_name refuses and those for which child_path fails with EACCES, EINVAL, or E2BIG, and READDIRPLUS skips a listed entry whose path a rename has since made longer than MAX_PATH_BYTES, while the bound on the names that the nodes hold still fails it at an entry. Its tests fail without the fix on Windows and Linux, at the listing, and pass with it. At the pin, the tests of the virtiofs package pass on Windows and Linux. No saved-state, protocol, or ABI 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 25, 2026
…penVMM roadmap Map position 397, the commit of microsoft/openvmm#5289, which NVX now pins at a79b4bb40, 271 commits past the mapped tip, on 1495ac815, position 396, the head of microsoft/openvmm#5288: - 397, virtiofs: leave entries that lookups refuse out of microVM listings. The listing that the first read of a microVM directory handle takes leaves out the entries whose names fuse::check_name refuses, such as one longer than 255 bytes, and those whose child_path fails with EINVAL, for a name that the share refuses, or with E2BIG, for a path longer than MAX_PATH_BYTES, as it left out those that fail with EACCES, rather than fail and hide every other entry of the directory (#2133), and READDIRPLUS skips a listed entry whose path a rename of an ancestor has since made too long. Position 397 is not yet assigned to a PR: it fixes defects of PR18's positions 081 and 083, but its code changes the closure that position 371's loop calls, around position 160's entry_listable and position 385's check of the bounds, which position 083 lacks, and its tests follow position 385's, so it is not a PR18 fixup, unlike positions 389, 393, and 396. Of positions 372-396, only 385, 389, 390, 393, and 396 change its files: position 385 the closure of the microVM's file.rs that it changes, and all five other tests of fs_tests.rs. Upstream main, 8d4e03132, lacks the defects, since it lacks the microVM's directory listings, and replaying the commit there conflicts in the microVM's file.rs and fs_tests.rs, which upstream main lacks, so it cannot go upstream on its own. The Scope also names the head of feature/microvm/dev, 770bc61e7, since microsoft/openvmm#5282 landed position 390. 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 25, 2026
A microVM aggregate's saved state whose node table was empty and whose next node ID was 1, FUSE_ROOT_ID, restored (#2134). Node 1 of an aggregate is its synthetic root, which has no saved node, so the next lookup of a child gave the child's root node 1, the device routed every request for that node to the synthetic root, and the device's next save could not restore. The device never saves such a state, so only a corrupt or crafted state reaches this. Pin microsoft/openvmm 5f4a47b83591ccbcc4f9a2563b5322603def625b, the head of microsoft/openvmm#5290, one commit on a79b4bb40, the head of microsoft/openvmm#5289, which NVX pins below this commit: - virtiofs: refuse a microVM aggregate state whose next node ID is 1. validate_microvm_state, which the device's saved-state validator and restore_microvm_state run before they change any state, requires the next node ID to exceed FUSE_ROOT_ID as well as every saved node ID, which changes nothing for a single share, whose root is its saved node 1. Its test fails without the fix, since the restore succeeds, and passes with it, on Windows and on Linux. At the pin, the tests of the virtiofs package pass on Windows and Linux, and NVX's filesystem-snapshot, platform-aggregate-export, and filesystem-shares microVM scenarios pass on KVM. No saved-state, protocol, or ABI 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 25, 2026
…nVMM roadmap Map position 398, the commit of microsoft/openvmm#5290, which NVX now pins at 5f4a47b83, 272 commits past the mapped tip, on a79b4bb40, position 397, the head of microsoft/openvmm#5289: - 398, virtiofs: refuse a microVM aggregate state whose next node ID is 1. validate_microvm_state requires the next node ID to exceed FUSE_ROOT_ID as well as every saved node ID, so that a restore no longer accepts an aggregate state without nodes whose next node ID is that of the synthetic root, which has no saved node, and then gives the synthetic root's node to the first child that the guest looks up (#2134). Position 398 is not yet assigned to a PR: it fixes a defect of position 164, which no PR maps, since PR18's position 083's check of the next node ID held as long as every state saved its root as node 1, which position 164's aggregates do not, so it is not a PR18 fixup, unlike positions 389, 393, and 396. Of positions 372-397, only 390, 393, and 396 change its files, all three the microVM's state.rs's reopen_flags, and position 390 also the check of writable handles after the check that it changes. Upstream main, 8d4e03132, lacks the defect, since it lacks the microVM's saved state, and replaying the commit there conflicts in the microVM's state.rs and aggregate_fs_tests.rs, which upstream main lacks, so it cannot go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
merged commit Nov 26, 2026
a79b4bb
into
feature/microvm/dev
104 of 105 checks passed
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#2133.
Stacked on #5288 (
1495ac815, branchcopilot/nvx-issue-2129-virtiofs-create-flags), itself stacked on #5287 (4aeb405d9), #5286 (9822f732a), #5285 (5af753b17), #5284 (e61fa5326), #5283 (c7f6a04fd), #5282 (770bc61e7), and #5281 (350018ce4), whose commits this pull request includes; only its top commit,a79b4bb40, belongs to it. NVX pins the head of this branch,a79b4bb40da0662a873798a094209cc9be59eb32, in the NVX pull request of microsoft/nvx#2133 (branchagents/issue-2133-virtiofs-unreachable-entries), so this pull request is a prerequisite of that NVX change. It lands after #5281, #5282, #5283, #5284, #5285, #5286, #5287, and #5288 by fast-forwardingfeature/microvm/devto that exact commit, not with the merge button, which squashes.What and why
A microVM guest could not list a host directory that held a single entry whose name or path every lookup refuses: a guest's busybox
ls -aof such a share printed no name, not even.and.., although the guest could still look up the directory's other entries by name. The firstFUSE_READDIRorFUSE_READDIRPLUSof a directory handle lists the directory into a snapshot, from which every later read pages, inVirtioFsFile::build_microvm_directory_snapshot_within(microvm/file.rs). The listing left out the entries whose paths the access policy hides, for whichchild_pathfails withEACCES, but failed for every other refusal ofchild_path:EINVALfor a name that the share refuses, such as one that holds:or\, which a Windows host also lists for the private-use characters that stand for them, as in the names that WSL gives such files, andE2BIGfor a path longer thanMAX_PATH_BYTES, as the paths of a directory's entries become when the guest renames an ancestor to a longer name. Before the policy filter, it also failed withEINVALfor a name longer than 255 bytes, which a Windows name of fewer UTF-16 code units can be, althoughfuse::check_namerefuses such a name in every FUSE request. Every later read of the handle then failed too. Both date from6315c16c5(virtiofs: persist microVM FUSE namespaces, handles, and directory cookies), which introduced the listings.fuse::check_namerefuses, as the parser of every FUSE request does, and those for whichchild_pathfails withEACCES,EINVAL, orE2BIG, as it does for a lookup. They count toward neither bound of a listing. The listing no longer checks the length of the names that it holds itself:check_namebounds them by NAME_MAX, 255 bytes, the bound of a saved listing's names, whichvalidate_directory_entriesstill checks.FUSE_READDIRPLUSlooks up each entry of a listing, which a handle may have taken before such a rename, and failed at an entry whose path the rename made longer thanMAX_PATH_BYTES, and with it every later read, since each starts at that entry.write_microvm_entry_plusnow reports such an entry as gone, withENOENT, whichread_dir_microvmskips, as a new listing would leave the entry out. Only the lookup fails withE2BIGfor such a path: theE2BIGwith whichinsert_lookuprefuses a node once the nodes hold 1 MiB of names still fails the read, since the guest can reach the entry once it forgets other nodes.Left as it is:
FUSE_READDIRPLUSleaves it out, as before.read_dir_with, which lists the directories of shares other than microVM shares, does not change.No saved state, protocol, ABI, or format, and no version of any of them, changes.
Tests
In
microvm/fs_tests.rs, aftermicrovm_listings_count_only_the_entries_that_the_policy_shows:microvm_listings_leave_out_names_that_the_share_refuses: a share that holdsplainand names with:and\, and on Windows the private-use characters that stand for them and for NUL. A lookup of each refused name fails withEINVAL, andFUSE_READDIRandFUSE_READDIRPLUSlist.,.., andplain.microvm_listings_leave_out_entries_whose_paths_exceed_the_bound: a directory belowaholdsshortand a 200-characterlong. Once the guest renamesato a name of 255 characters, the path oflongexceedsMAX_PATH_BYTESand its lookup fails withE2BIG; a new handle lists.,.., andshortwith both reads, and so doesFUSE_READDIRPLUSof the listing taken before the rename, restored into a handle, since Windows renames no directory below an open handle.microvm_listings_leave_out_names_longer_than_a_request_carries, on Windows only, whose file systems hold names longer than 255 bytes: a share that holds a name of 300 bytes lists.,.., andplain.readdirplus_fails_at_an_entry_whose_node_exceeds_the_bound_on_names:FUSE_READDIRPLUSstill fails withE2BIGat an entry whose node the bound on the nodes' names refuses.Validation
On Windows 11 Enterprise (NTFS) and on a Linux KVM test VM (Azure Linux 3, kernel 6.18, x86_64, tmpfs), with Rust 1.97.1:
1633b3797, the head offeature/microvm/dev, the first three tests fail at the listing on Windows, withEINVAL,E2BIG, andEINVAL, and the first two fail on Linux. With only the listing's part of the fix,FUSE_READDIRPLUSof the earlier listing still fails withE2BIG. The fourth passes there, as it must, and fails ifFUSE_READDIRPLUSskips everyE2BIG.1633b3797(23a2f69d6):cargo check,cargo clippy --all-targets, andcargo doc --no-depsofvirtiofshave no warnings on Windows and Linux;cargo nextest run --profile agent -p virtiofspasses 244 tests on Windows (3 skipped) and on Linux (1 skipped);cargo xtask fmt --fixchanges nothing.ls -aof a read-only share that holdsplain,a:b, anda\bprinted no name with the release OpenVMM of1633b3797, whilels /share/plainfound the file, and printed.,.., andplainwith OpenVMM built from the fix. On WHP, a share that holdsplain, the private-use names that stand fora:banda\b, and a name of 300 bytes printed the same before and after.git range-diffreports. Ata79b4bb40,cargo clippy --all-targets -p virtiofshas no warnings on Windows and Linux,cargo nextest run --profile agent -p virtiofspasses 249 tests on Windows (3 skipped) and on Linux (1 skipped), andcargo xtask fmt --fixchanges nothing.a79b4bb40passedunit tests [x64-linux],unit tests [x64-windows], andrun vmm-testsofx64-linux-amd-kvm,x64-linux-intel-mshv,x64-windows-intel, andx64-windows-amd.run vmm-tests [x64-windows-amd-snp]failed, as it does at1495ac815,4aeb405d9, and1633b3797.