Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/design/3.6-host-filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ describes.
An aggregate's root lists its children in declaration order and refuses every
change with `EROFS`. A child is a host directory or a single regular file. The
declared kind, not the host object, decides which, and the VMM refuses a host
path of the other kind. A file child serves only its file, as the child
path of the other kind. It also refuses a file whose name contains `\` or `:`,
which the server refuses in every path of an export, so the guest could never
reach it. A file child serves only its file, as the child
itself: its volume is the file's parent directory, narrowed to the file's
name, which the guest never reaches, so the guest cannot list or change
anything beside the file, a lookup below it fails with `ENOTDIR`, and every
Expand Down
49 changes: 39 additions & 10 deletions doc/openvmm-upstream-roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
- Mapped fork tip: `1e492803287f04b40bb7c17e8648c4b96af52ecc`, position 126. The graph, PR
summary, and commit mapping below cover positions 001-126, the PR18 fixups at positions 302,
333, and 342, and the PR13 fixup at position 340.
- NVX's pinned OpenVMM revision: `5c82edac42ca480d546459e019860759a27c2211`, position 342, the head
of microsoft/openvmm#5208, whose commit follows position 341, `ed2d7e3a1`, the head of
- NVX's pinned OpenVMM revision: `afa0e9c20a7943d3ec556098d9272f4ee502bdd4`, position 343, the head
of microsoft/openvmm#5209, whose commit follows position 342, `5c82edac4`, the head of
microsoft/openvmm#5208, whose commit follows position 341, `ed2d7e3a1`, the head of
`feature/microvm/dev`, where microsoft/openvmm#5207 landed position 341 on position 340,
`32888344a`, where microsoft/openvmm#5206 landed position 340 on position 339, `b51f9156c`, the
head of the `feature/microvm/release/v7.2` branch of microsoft/openvmm. The
Expand All @@ -19,9 +20,9 @@
landed, so each later commit's position is one less than before, and it added five fixups at its
tip, positions 335-339. Of the 334 replayed commits, 47 conflicted with upstream and 13 replayed
with new context; see [Conflicts of the v7.2 rebase](#conflicts-of-the-v72-rebase). The pin is
216 commits past the mapped tip on the same first-parent chain. Positions 127-301, 303-332, 334,
and 341 are not yet assigned to PRs, positions 302, 333, and 342 are PR18 fixups, position 340
is a PR13 fixup, and positions 316 and 335-339 are rebase fixups; see
217 commits past the mapped tip on the same first-parent chain. Positions 127-301, 303-332, 334,
341, and 343 are not yet assigned to PRs, positions 302, 333, and 342 are PR18 fixups, position
340 is a PR13 fixup, and positions 316 and 335-339 are rebase fixups; see
[Commits after the mapped tip](#commits-after-the-mapped-tip).
- Upstream main: `bf353460ff70e4a65627bb7003bed2cad1ce121f` (2026-11-21), the fork base; see
[Upstream main past the fork base](#upstream-main-past-the-fork-base).
Expand Down Expand Up @@ -1619,7 +1620,8 @@ bf353460f
-> PR13 fixup [340]
-> virtio-fs aggregate root reads bounded at 1 MiB [341]
-> PR18 fixup [342]
-> 5c82edac4 (NVX pin)
-> microVM file children whose names hold `\` or `:` refused [343]
-> afa0e9c20 (NVX pin)
```

For upstream review, PR01-PR03, PR05, PR06, and PR14 can be rebased independently onto current
Expand Down Expand Up @@ -1658,7 +1660,7 @@ the policy tests share the `request` helper that the tests call.

## Commits after the mapped tip

The NVX pin extends the chain past position 126 without merges. Of its 216 later commits, positions
The NVX pin extends the chain past position 126 without merges. Of its 217 later commits, positions
302, 333, and 342 are PR18 fixups, position 340 is a PR13 fixup, position 316 is the fixup of the
v7.1 rebase, positions 335-339 are the fixups of the v7.2 rebase, and the others are not yet
classified or assigned to PRs.
Expand All @@ -1669,15 +1671,15 @@ of the v4.0 reorganization, positions 201-206 followed it, positions 207-213 fol
reorganization, positions 214 and 215 followed the v5.1 rebase, positions 216-253 followed the
v6.0 reorganization, positions 254-296 followed the v6.1 rebase, positions 297-315 followed the
v7.0 reorganization, position 316 is the v7.1 rebase's fixup, positions 317-334 followed the
v7.1 rebase, positions 335-339 are the v7.2 rebase's fixups, and positions 340-342 followed the
v7.1 rebase, positions 335-339 are the v7.2 rebase's fixups, and positions 340-343 followed the
v7.2 rebase, so they combine none, apart from
position 215, which combines v5.1 positions 222 and 223, and the commits that the v7.0
reorganization folded into them. Each commit through position 316 has the position that it had in
v7.0 and v7.1, and each of positions 317-334 is its v7.1 position less one, since the v7.2 rebase
dropped v7.1 position 317, upstream's microsoft/openvmm#5160, which v7.1 had backported. Each
commit's v6.1 position is its v6.0 position less seven, the number of commits that the v6.1 rebase
dropped before it, and its v6.0 position is its v5.1 position through 147 and one less from v5.1
position 149 on, and positions 297-342 have no earlier position; see
position 149 on, and positions 297-343 have no earlier position; see
[Conflicts of the v7.2 rebase](#conflicts-of-the-v72-rebase),
[The v7.0 reorganization](#the-v70-reorganization),
[Conflicts of the v6.1 rebase](#conflicts-of-the-v61-rebase), and
Expand Down Expand Up @@ -1906,6 +1908,7 @@ whose first 220 commits are those of `feature/microvm/release/v6.0`, and a v4.0
| 340 | `32888344a` | - | - | - | - | - | - | virtiofs: keep node names when renaming a name onto itself (microsoft/openvmm#5206); fold into 048, its test into 166 |
| 341 | `ed2d7e3a1` | - | - | - | - | - | - | virtiofs: bound the buffer of an aggregate root's directory read (microsoft/openvmm#5207) |
| 342 | `5c82edac4` | - | - | - | - | - | - | virtiofs: bound microVM directory snapshots in total when listing (microsoft/openvmm#5208); fold into 083, its budget in `new_microvm_aggregate` and its tests into 164 |
| 343 | `afa0e9c20` | - | - | - | - | - | - | virtiofs: refuse a microVM file child that its volume cannot name (microsoft/openvmm#5209) |

The remarks that say whether commits apply to upstream main record what was found on upstream main
when each commit was mapped: the v3.0 reorganization's base, `b2676222b`, for the commits that it
Expand All @@ -1916,7 +1919,7 @@ and `c0694c4da`, upstream main on 2026-11-16, for positions 297-306, `c4419be15`
main on 2026-11-19, for positions 321-324, `78af54a51`, upstream main on 2026-11-20, for position
325, `d83f87209`, upstream main later that day, for position 326, `265f0a73f`, upstream main
later still, for positions 327 and 328, and `bf353460f`, upstream main on 2026-11-21 and the v7.2
fork base, for positions 329-334 and 340-342.
fork base, for positions 329-334 and 340-343.
They name the positions that the commits have now, but neither the v7.2 rebase on `bf353460f`, the
v7.1 rebase on `9a875b563`, nor the v7.0 reorganization on `e6b458cc0` checked them again, nor did
the v6.1 rebase check the earlier ones on `7d90c4104`.
Expand Down Expand Up @@ -4374,6 +4377,32 @@ since it lacks the microVM persistence. Replaying the commit there conflicts in
`lib.rs`, next to the code of positions 081, 083, and 158, and in the microVM's `file.rs`, `fs.rs`,
and `fs_tests.rs`, which upstream main lacks, so it follows PR18 upstream.

Position 343 has `open_microvm_volume` refuse the file of an aggregate's file child whose name holds
`\` or `:`, so that attaching the aggregate fails, at a cold boot or a restore, with an error that
names the file (microsoft/nvx#1614). Position 165 opens the file's host directory as a strict
volume whose root object is the file, at its name, and PR18's position 081 has a strict volume
refuse every path with `\` or `:`, in `validate_relative_path`, which the preflight of an insert
that position 081 adds, the confinement check that PR27's position 126 adds, and the save and
restore of PR18's position 083 apply to every name of a node. Nothing checked the file's name
when the child attached, since the profile's path rules cover only the policy paths that it
parses, so a file child whose name had one, common on Linux, as in timestamps or digests, and on
Windows the name of an alternate data stream of a file, attached, but every guest `LOOKUP` of it
failed with `EINVAL`, and so did a `READDIRPLUS` of the aggregate's root from the child on, while
a plain `READDIR` listed it as a regular file. The commit applies the same `validate_relative_path`
to the file's name; a directory's own name is never a path of its volume, so directory shares and
children are unchanged, and the saved state keeps its format. It changes the file branch of
`open_microvm_volume` in the microVM's `fs.rs`, which position 164 adds and position 165 extends
to files, and the rustdoc of `new_microvm_aggregate`, which position 164 adds and position 165
changes; PR18's positions 081, 083, and 085, PR22's position 102, PR27's position 126, and
positions 158, 160, 194, 332, and 342 also change the file. It adds tests to the microVM's
aggregate tests, which position 164 adds and positions 165, 194, and 341 also change, and a bullet
to the "Single files" part of the Guide's virtio-fs page, which position 165 adds. It fixes a
defect of position 165, which no PR maps, so it is not yet assigned to a PR either and follows
position 165. Upstream main lacks the defect, since it lacks the microVM profile and its file
children. Replaying the commit there conflicts in all three files, which upstream main lacks: the
microVM's `fs.rs` and `aggregate_fs_tests.rs` and the Guide's virtio-fs page, so it cannot go
upstream on its own.

## PR summary

Each count is of v7.2 commits, which include the fixups that the v3.0, v4.0, v5.0, v6.0, and v7.0
Expand Down
6 changes: 5 additions & 1 deletion doc/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,11 @@ children are the outermost mapped directories and the mapped files outside
them, so a `--mount` of a directory again, or of a path inside a mapped
directory, maps a part of that directory's child rather than a child of its
own. OpenVMM's `file` flag marks a child that is a shared file, so OpenVMM
refuses a directory that replaced the file rather than export all of it. A
refuses a directory that replaced the file rather than export all of it.
OpenVMM refuses a colon or a backslash in every path of a share, and so a
file child whose name contains one, such as a Windows path that names an
alternate data stream, which the guest could never reach; NVX rejects such a
file child before boot. A
child is read-write only if it holds a read-write mapping, and OpenVMM then
limits its writes to its read-write mappings, which NVX passes as
`--mount-write` paths when they lie inside a read-only one. A read-only
Expand Down
9 changes: 9 additions & 0 deletions nvx/src/host/filesystem/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ pub(super) fn check_root(root: &Path) -> Result<()> {
Ok(())
}

/// Explains why OpenVMM cannot export the file `file` alone, as a child, or returns `None` if it
/// can. OpenVMM reaches the file by its name, in which it refuses a colon or a backslash, as in
/// every path of an export, such as a Windows path that names an alternate data stream of a file.
pub(super) fn file_name_problem(file: &Path) -> Option<&'static str> {
file.file_name()
.is_some_and(|name| name.to_string_lossy().contains([':', '\\']))
.then_some("has a colon or a backslash in its name")
}

/// Applies OpenVMM's rules for the paths that it is to `action` in the exported directory `root`,
/// so a policy that OpenVMM would refuse fails at provision rather than at every start: those of
/// [`policy_limits`], and on the host, no link or reparse point below `root` and no other file
Expand Down
13 changes: 11 additions & 2 deletions nvx/src/host/filesystem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub(crate) use self::host_path::{canonicalize, is_reparse_point};
#[cfg(feature = "cli")]
use self::host_path::{identity, relative_text};
#[cfg(feature = "cli")]
use self::limits::{check_policy_paths, check_root};
use self::limits::{check_policy_paths, check_root, file_name_problem};
#[cfg(feature = "cli")]
use self::policy::{
Writable, allowed_paths, canonicals, check_allowed_paths, check_read_only, check_write_paths,
Expand Down Expand Up @@ -360,7 +360,8 @@ pub(crate) struct ExportRequest<'a> {
/// target is mapped once, read-only if either mapping is. Two objects never share a target, and a
/// target inside another mapping's must show the very object that the other mapping shows there.
/// A whole volume cannot be mapped, and a policy that would need more children than OpenVMM
/// offers is refused.
/// offers is refused. A file that a child exports alone must not have a colon or a backslash in
/// its name, which OpenVMM refuses in every path of an export.
///
/// A read-only path must not lie inside a writable part, where the host could not keep it
/// read-only: inside a read-write directory, unless write paths narrow that directory's writes
Expand Down Expand Up @@ -496,6 +497,14 @@ pub(crate) fn plan(request: &ExportRequest<'_>) -> Result<Option<PlannedExport>>
let child_allowed = inside(&allowed);
let child_denied = needed_denied_paths(&inside(&denied), &child_allowed);
check_root(root)?;
if !own.directory
&& let Some(problem) = file_name_problem(root)
{
return unsupported(format!(
"OpenVMM cannot export {}, which {problem}",
root.display()
));
}
policy_bytes += check_policy_paths(root, &child_denied, "hide")?;
policy_bytes += check_policy_paths(root, &child_allowed, "show again")?;
policy_bytes += check_policy_paths(root, &part.write, "make writable")?;
Expand Down
58 changes: 58 additions & 0 deletions nvx/src/host/filesystem/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,64 @@ fn policy_paths_follow_openvmm_rules() {
}
}

/// OpenVMM reaches a file that a child exports alone by its name, and refuses a colon or a
/// backslash in every path of an export, so the planner refuses such a file, and a recorded plan
/// that exports one fails its check, but not a file in a directory with such a name, which OpenVMM
/// opens by its host path.
#[cfg(feature = "cli")]
#[test]
fn files_named_with_colons_or_backslashes_are_not_exported_alone() {
let directory = root();
let base = directory.path();
let names: &[&str] = if cfg!(windows) {
// A Windows path with a colon in its last name names an alternate data stream.
&["config.json:stream"]
} else {
&["colon:here.txt", "back\\slash.txt"]
};
let refused = |error: Error| {
assert_eq!(error.kind(), ErrorKind::Unsupported, "{error}");
assert!(
error.message().contains("a colon or a backslash"),
"{error}"
);
};
for name in names {
let file = base.join("work").join(name);
fs::write(&file, b"notes").unwrap();
let policy = FilesystemPolicy {
readonly_paths: vec![file],
..FilesystemPolicy::default()
};
refused(plan(&policy).unwrap_err());
}
// A plan recorded before the planner refused such a file is refused when it is read back.
let plain = plan(&FilesystemPolicy {
readonly_paths: vec![base.join("work").join("config.json")],
..FilesystemPolicy::default()
})
.unwrap()
.unwrap();
plain.check(ReservedTargets::BLOCKLESS_ROOT).unwrap();
for name in names {
let mut recorded = plain.clone();
recorded.children[0].root.set_file_name(name);
refused(recorded.check(ReservedTargets::BLOCKLESS_ROOT).unwrap_err());
}
if !cfg!(windows) {
let file = base.join("colon:dir").join("notes.txt");
fs::create_dir(file.parent().unwrap()).unwrap();
fs::write(&file, b"notes").unwrap();
let policy = FilesystemPolicy {
readonly_paths: vec![file.clone()],
..FilesystemPolicy::default()
};
let mapping = plan(&policy).unwrap().unwrap();
assert_eq!(mapping.children[0].root, canonical(&file));
assert!(mapping.children[0].file);
}
}

#[cfg(feature = "cli")]
#[test]
fn openvmm_limits_are_checked_per_directory() {
Expand Down
15 changes: 12 additions & 3 deletions nvx/src/host/filesystem/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::PathBuf;

use super::guest_path::depth;
use super::host_path::{display_path, relative_text};
use super::limits::policy_limits;
use super::limits::{file_name_problem, policy_limits};
#[cfg(feature = "cli")]
use super::policy::Writable;
use super::policy::{nearest_rule, policy_rule_problem};
Expand All @@ -30,8 +30,9 @@ impl ExportPlan {
/// root that reserves `reserved`: at least one and at most [`MAX_CHILDREN`] children, none
/// inside another, each an absolute host path below a volume's root, with its host paths
/// resolved, without a NUL character or a `..` component, and, on Windows, on a local drive,
/// without the verbatim prefix, whose policy paths lie inside it within OpenVMM's limits and
/// keep its rules, and writable exactly when a bind maps a path of it read-write; and at least
/// without the verbatim prefix, each file without a colon or a backslash in its name, whose
/// policy paths lie inside it within OpenVMM's limits and keep its rules, and writable exactly
/// when a bind maps a path of it read-write; and at least
/// one and at most [`MAX_HOST_MAPPINGS`] binds, each of a known child, from a relative source
/// that holds the host's names joined with `/`, that a guest path can hold, and that the child
/// does not hide, unless it shows paths inside it again, to a free guest target, parents before
Expand Down Expand Up @@ -80,6 +81,14 @@ impl ExportPlan {
"child {index} has the host path {path:?}, which {problem}"
));
}
if child.file
&& let Some(problem) = file_name_problem(&child.root)
{
return invalid(format!(
"child {index}, {}, is a file that {problem}, which OpenVMM cannot export",
child.root.display()
));
}
if let Some(path) = [&child.denied, &child.allowed, &child.write]
.into_iter()
.flatten()
Expand Down
Loading