Skip to content

sandbox: match a --layer name's non-ASCII letters in any case on Windows - #2241

Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
agents/issue-2240-layer-name-unicode-case
Nov 27, 2026
Merged

Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
agents/issue-2240-layer-name-unicode-case

Conversation

@ppenna

@ppenna Pedro Henrique Penna (ppenna) commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2240

What does this pull request change?

On Windows, nvx sandbox run and nvx sandbox provision now accept a distro
layer whose --layer path spells a non-ASCII letter of the layer's file name in
another case than the manifest's artifact field, such as
--layer distro,DIR\couche-É.erofs,UUID for DIR\couche-é.erofs, whose
manifest names couche-é.erofs. Before, they failed with
error[unsupported]: sandbox distro manifest does not match its artifact,
although Windows opens the layer and its manifest through that spelling. A
manifest that names another artifact, such as couche-è.erofs, is still
refused, and the digest still binds the manifest to the layer's bytes.

  • host::paths::is_named, which explicit verification uses to compare the
    manifest's artifact with the layer's file name, now compares names on
    Windows with CompareStringOrdinal, ignoring case through the operating
    system's uppercase table, through a new helper of the Windows platform layer,
    is_same_file_name. It still compares names exactly elsewhere, so Linux and
    macOS are unchanged.
  • windows-sys gains its Win32_Globalization feature, which declares the
    function; Cargo.lock does not change.
  • The documentation that said "in any ASCII case" now says any case:
    nvx/src/host/paths.rs, nvx/src/host/sandbox/distro.rs, the README's
    Distro bindings, and doc/run.md.

Start with is_same_file_name in nvx/src/host/platform/windows/mod.rs, then
is_named in nvx/src/host/paths.rs, then the test in
nvx/src/host/sandbox/distro/tests.rs.

Left out, and limitations that remain: root discovery, the other caller of
is_named, compares path components only with bin, nvx, and target, so
its matches do not change. The comparison ignores case even in a directory
whose per-directory case sensitivity is enabled, as the ASCII comparison did,
and it uses the operating system's uppercase table, which may differ from that
of a volume that an older Windows formatted for letters that the newer table
added. An 8.3 short-name spelling, such as COUCHE~1.ERO, already provisioned,
since no manifest opens beside it and provision verifies the layer again at
its resolved long path.

Why is this change needed?

Root cause: explicit verification,
verify_with,
compares the artifact with the file name of the path given through
paths::is_named,
which on Windows called OsStr::eq_ignore_ascii_case: it folded the case of
ASCII letters alone, while Windows' own lookups, which found the layer and its
manifest through that spelling, ignore the case of every letter that the
uppercase table maps, such as é and É. #2138, the fix of #2131, introduced
the ASCII-only comparison. A user or script that spells a layer's name with a
non-ASCII letter in another case cannot run or provision a sandbox from it,
and snapshot restore shares the code path.

Alternatives rejected:

  • Case folding in user space, such as char::to_uppercase: its full mappings
    over-match (ß becomes SS, which Windows does not match), and its Unicode
    version need not be the operating system's. OpenVMM's fix of openvmm: virtiofs: Windows case-insensitive lookup and NTFS 8.3 short names bypass microVM SubtreePolicy #1603 (openvmm: pin the Windows name checks of microVM shares #1963)
    rejected user-space case folding for the same reason.
  • Checking that the artifact in the layer's directory opens the layer, by file
    identity: exact under per-directory case sensitivity, but it changes what
    "names the layer" means on every host, so that hard links and symbolic links
    would match too, and it opens a path that the manifest names.
  • Comparing with the name under which the file system stores the layer: the
    manifest may still spell that name in another case, so it needs the same
    case-insensitive comparison.

How was this change validated?

Checks and results:

  • Regression test, cargo test --locked --all-features --lib -- host::sandbox::distro::tests::verification_takes_the_manifest
    on Windows: at 2e302197d90 with the test alone, the new
    verification_takes_the_manifest_of_a_layer_whose_path_spells_a_non_ascii_letter_in_another_case
    failed with called Result::unwrap() on an Err value: Error { code: Unsupported, message: "sandbox distro manifest does not match its artifact", source: None },
    while nvx: on Windows, sandbox run and provision refuse a distro layer whose --layer path spells its file name in another case #2131's ASCII test passed. With the fix, both pass, and the 24 tests of
    host::sandbox::distro, host::paths, and host::cli::artifacts pass.
  • The reproduction of nvx: on Windows, sandbox run and provision refuse a --layer path that spells a non-ASCII letter of the layer's name in another case #2240, with the nvx CLI and no VM: at 2e302197d90,
    sandbox provision --upper ram exited with 0 for the exact and the
    ASCII-case spellings and with 1 and the error above for the non-ASCII-case
    spelling, and sandbox run --dry-run failed the same way. With the fix, all
    three spellings provision (the non-ASCII one records the on-disk name), the
    run goes on to its artifact checks (artifact-missing in a checkout without
    artifacts), and a manifest that names couche-è.erofs still fails with
    exit 1.
  • python scripts\local_gates.py --base origin/dev --run on Windows, with
    NVX naming a release build and Git's usr\bin on PATH: test-changes,
    markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc,
    nvx-msrv, and nvx-cli passed.
  • cargo clippy --locked --target x86_64-unknown-linux-gnu with
    --all-targets --all-features, --lib --bins --features cli, and --lib,
    each with -D warnings: passed. cargo check --locked --all-targets --all-features --target aarch64-apple-darwin: passed.
  • A code review of the whole diff found no issues.

Backend, host OS, host type, and guest:

Profile Backend Host OS and type Before the fix After the fix
Local workstation, a fallback: azure-intel-whp-1 to -7, -11, -12, and azure-amd-whp-1 to -4 were unreachable WHP host, no VM needed Windows 11 Enterprise, NTFS; local, no recorded host type The non-ASCII-case spelling is refused It provisions; another artifact is still refused

No guest ran: the change is in the CLI's verification before any launch.

Left to CI, and passed there: run
45938019508 of
055c4a335d5 passed the Linux and Windows jobs of the nvx crate, including
its tests on Linux, whose behavior is unchanged, the NVX CLI on Linux and
Windows, the guest and OpenVMM builds, and the microVM tests on KVM, MSHV, and
WHP; the public API check ran there too.

Checklist

  • Tests cover the new or fixed behavior, in the layout that
    python3 scripts/check_test_layout.py checks.
  • python3 scripts/check_test_changes.py --base origin/dev lists no change
    to an existing test, or a Changes to existing tests section below
    explains each one.
  • The documentation that the change affects is updated, including
    .github/copilot-instructions.md and the skills when a convention or
    workflow changes.
  • A change to the public API of nvx updates nvx/public-api/ with
    python3 scripts/public_api.py --update.
  • Snapshots, protocols, and on-disk formats stay compatible, or the
    description says how the change versions or migrates them.

On Windows, sandbox run and provision refused a distro layer whose
--layer path spelled a non-ASCII letter of the layer's file name in
another case than its manifest's artifact field, such as
DIR\couche-É.erofs for DIR\couche-é.erofs, whose manifest names
couche-é.erofs. They failed with "sandbox distro manifest does not
match its artifact" before they compared the digest (#2240), although
NTFS ignores the case of non-ASCII letters too, so the layer and its
manifest opened through that spelling. A spelling that differs only in
the case of ASCII letters, which #2131 fixed, already passed.

Explicit verification compares the artifact with the layer's file name
through host::paths::is_named, which on Windows compared the names with
OsStr::eq_ignore_ascii_case. That folds the case of ASCII letters
alone, while Windows' own lookups ignore the case of every letter that
the operating system's uppercase table maps.

On Windows, is_named now compares the names with CompareStringOrdinal,
ignoring case, through a new platform helper, is_same_file_name: the
comparison that uses the operating system's uppercase table, as the
file system does, rather than case folding in user space. Elsewhere it
still compares names exactly. A manifest that names another artifact,
such as couche-è.erofs, still fails, and root discovery, the other
caller, compares names with bin, nvx, and target, whose matches do not
change. The documentation that said "in any ASCII case" now says any
case. windows-sys gains its Win32_Globalization feature, which declares
the function.

Evidence, on a local Windows 11 workstation (NTFS), with the CLI and no
VM, since no configured WHP host was reachable: at 2e30219, sandbox
provision --upper ram with --layer DIR\couche-É.erofs exited with 1 and
the error above, and sandbox run --dry-run failed the same way, while
the exact and the ASCII-case spellings provisioned. With the fix, all
three spellings provision, the run goes on to its artifact checks, and
a manifest that names couche-è.erofs is still refused.

Tests: on Windows, the verification of a layer through a path that
spells a non-ASCII letter of its name in another case fails at
2e30219 and passes with the fix; the test also checks that a
manifest of another letter is still refused.

Refs #2240.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 04:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the Windows non-ASCII layer-name matching change.

No open issues 🎉

What changed in this PR

Fixes #2240 by extending Windows sandbox layer-name verification to accept non-ASCII case differences. This builds on #2138’s ASCII-only fix while preserving exact matching on Linux and macOS and leaving digest verification unchanged.

Changes:

  • Uses Windows CompareStringOrdinal for case-insensitive name matching and enables the required windows-sys feature.
  • Adds a Windows regression test accepting é/É while rejecting a different letter.
  • Updates documentation to describe non-ASCII case matching.
File Description
nvx/​src/​host/​sandbox/​distro/​tests.rs Tests non-ASCII case acceptance and mismatched-name rejection.
nvx/​src/​host/​sandbox/​distro.rs Updates verification documentation to remove the ASCII-only limitation.
nvx/​src/​host/​platform/​windows/​mod.rs Adds the Windows name-comparison helper using the operating system’s uppercase table.
nvx/​src/​host/​paths.rs Routes Windows name matching through the new helper; retains exact matching elsewhere.
nvx/​README.md Updates the documented distro-binding name comparison.
nvx/​Cargo.toml Enables windows-sys’s Win32_Globalization feature.
doc/​run.md Documents non-ASCII case differences in --layer names on Windows.

Review effort: Balanced

@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 27, 2026
Merged via the queue into dev with commit cfdb721 Nov 27, 2026
58 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-2240-layer-name-unicode-case branch November 27, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nvx: on Windows, sandbox run and provision refuse a --layer path that spells a non-ASCII letter of the layer's name in another case

2 participants