Skip to content

Check virtio-fs DAX mappings against the DAX window - #537

Merged
Lencerf merged 3 commits into
google:mainfrom
Lencerf:fix/fs-dax-range
Nov 10, 2026
Merged

Lencerf merged 3 commits into
google:mainfrom
Lencerf:fix/fs-dax-range

Conversation

@Lencerf

@Lencerf Lencerf commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

The built-in and vhost-user virtio-fs devices map a file to, or unmap, a range
of the DAX window with MAP_FIXED, without checking that the range is within
the window. A guest (with FUSE_SETUPMAPPING or FUSE_REMOVEMAPPING) or a
vhost-user backend (with SHMEM_MAP or SHMEM_UNMAP) can replace any memory
mapping of the VMM process. In addition, VuFs panics at an unknown backend
request, stops the device when a SHMEM request fails, and replies even if the
backend did not ask for a reply.

  • Handle vhost-user SHMEM_MAP and SHMEM_UNMAP requests with DaxRegion, so
    that the built-in and vhost-user devices change the DAX window in one place.
  • Check that the range of a DAX mapping or unmapping is within the DAX window,
    returning EINVAL to the guest otherwise.
  • Return an error at an unsupported backend request instead of panicking; when a
    SHMEM request fails, log the error and reply a non-zero value without
    stopping the device; reply only when VHOST_USER_NEED_REPLY is set.

Every commit passes cargo +nightly fmt --check, cargo clippy --all-targets -D warnings on x86_64-unknown-linux-gnu/musl, aarch64-unknown-linux-gnu and
aarch64-apple-darwin, and cargo test --workspace locally.

To handle SHMEM_MAP and SHMEM_UNMAP requests from the backend, VuFs
repeats the mmap() calls of the DaxRegion implementation of ArcMemPages.
Call the DaxRegion methods instead, so that the built-in virtio-fs device
and the vhost-user one change the DAX window in one place.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
The DaxRegion implementation of ArcMemPages maps a file to, or unmaps,
a range of the DAX window with MAP_FIXED, but does not check that the
range is within the window. The guest gives the range in
FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING requests to the built-in
virtio-fs device, and the vhost-user backend gives it in SHMEM_MAP and
SHMEM_UNMAP requests to the vhost-user virtio-fs device. Either could
replace any memory mapping of the VMM process, e.g. with the contents of
a file it controls.

Fail a range outside the DAX window with a new InvalidDaxRange error,
which is EINVAL to the guest.

Fixes: b852e8c ("feat(fs): DAX support for built-in virtio fs")
Fixes: 359ab26 ("feat(fs): support virtio-fs DAX mapping")
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
VuFs panics at a backend request other than SHMEM_MAP and SHMEM_UNMAP,
and stops the device when a SHMEM request fails, e.g. with a range
outside the DAX window. It also replies to every request, even if the
backend did not set VHOST_USER_NEED_REPLY.

Return an error at an unsupported request instead of panicking: its
payload is unknown, so the backend channel cannot go on. When a SHMEM
request fails, log the error and reply a non-zero value, as the
vhost-user spec requires, and reply only if the backend asks for it.

Fixes: 359ab26 ("feat(fs): support virtio-fs DAX mapping")
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 42728235790

Coverage increased (+0.6%) to 40.356%

Details

  • Coverage increased (+0.6%) from the base build.
  • Patch coverage: 12 uncovered changes across 2 files (44 of 56 lines covered, 78.57%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
alioth/src/virtio/dev/fs/vu.rs 48 37 77.08%
alioth/src/fuse/fuse.rs 1 0 0.0%
Total (3 files) 56 44 78.57%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 16261
Covered Lines: 6356
Line Coverage: 39.09%
Relevant Branches: 1704
Covered Branches: 894
Branch Coverage: 52.46%
Branches in Coverage %: Yes
Coverage Strength: 903.42 hits per line

💛 - Coveralls

@Lencerf
Lencerf added this pull request to the merge queue Nov 10, 2026
Merged via the queue into google:main with commit 1b128ba Nov 10, 2026
20 checks passed
@Lencerf
Lencerf deleted the fix/fs-dax-range branch November 10, 2026 00:46
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.

2 participants