You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 81d6a88
Browse filesBrowse the repository at this point in the historyBrowse files
virtiofs: never hand out u64::MAX, the synthetic root's handle
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>
0 commit comments