Repository navigation
Check virtio-fs DAX mappings against the DAX window - #537
Merged
Merged
Conversation
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>
Coverage Report for CI Build 42728235790Coverage increased (+0.6%) to 40.356%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
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.
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 withinthe window. A guest (with
FUSE_SETUPMAPPINGorFUSE_REMOVEMAPPING) or avhost-user backend (with
SHMEM_MAPorSHMEM_UNMAP) can replace any memorymapping of the VMM process. In addition,
VuFspanics at an unknown backendrequest, stops the device when a
SHMEMrequest fails, and replies even if thebackend did not ask for a reply.
SHMEM_MAPandSHMEM_UNMAPrequests withDaxRegion, sothat the built-in and vhost-user devices change the DAX window in one place.
returning
EINVALto the guest otherwise.SHMEMrequest fails, log the error and reply a non-zero value withoutstopping the device; reply only when
VHOST_USER_NEED_REPLYis set.Every commit passes
cargo +nightly fmt --check,cargo clippy --all-targets -D warningson x86_64-unknown-linux-gnu/musl, aarch64-unknown-linux-gnu andaarch64-apple-darwin, and
cargo test --workspacelocally.