-
Notifications
You must be signed in to change notification settings - Fork 107
mmap: drop file-offset checking, defer to mmap(2)
instead
#320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
roypat
wants to merge
1
commit into
rust-vmm:main
Choose a base branch
from
roypat:stat-instead-of-seek
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
db86b91
to
cbced4a
Compare
ShadowCurse
previously approved these changes
Mar 24, 2025
1ba4642
to
d97d9cd
Compare
mmap(2)
instead
006c987
to
55dafa9
Compare
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 2, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 2, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 3, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 3, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 7, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 7, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 7, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 7, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 8, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 8, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 8, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 8, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 8, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 9, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 9, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 9, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to firecracker-microvm/firecracker
that referenced
this pull request
Apr 9, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
When mmap-ing a file-like object, vm-memory was trying to validate the the range [offset, offset+len) was valid in the file. However, our homegrown check had lots of edge cases where it gave false-positives (e.g. it rejected things that should really be working, such as vfio devices, or fds that cannot be seeked like guest_memfd), and trying to implement a check that works for all of these is in the end wasted effort anyway, because the kernel validates all this as part of the mmap syscall anyway. So just drop these checks in favor of failing at mmap-time. Drop a test case about mmap-ing a file of size 0 - this works because the mmap will simply grow the file. Signed-off-by: Patrick Roy <[email protected]>
4005762
to
e7518f7
Compare
ShadowCurse
approved these changes
Apr 16, 2025
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
roypat
added a commit
to roypat/firecracker
that referenced
this pull request
Apr 25, 2025
vm-memory has faulty validation logic that prevents us from mmap-ing guest_memfds, so just bypass that by calling mmap ourselves for the time being. See also rust-vmm/vm-memory#320 Signed-off-by: Patrick Roy <[email protected]>
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.
When mmap-ing a file-like object, vm-memory was trying to validate the
the range [offset, offset+len) was valid in the file. However, our
homegrown check had lots of edge cases where it gave false-positives
(e.g. it rejected things that should really be working, such as vfio
devices, or fds that cannot be seeked like guest_memfd), and trying to
implement a check that works for all of these is in the end wasted
effort anyway, because the kernel validates all this as part of the mmap
syscall anyway. So just drop these checks in favor of failing at
mmap-time.
See also #195 (comment)
Summary of the PR
Please summarize here why the changes in this PR are needed.
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s
), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafe
code is properly documented.