-
Notifications
You must be signed in to change notification settings - Fork 2k
virtio: skip redundant memory check #4723
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
Conversation
6df7337
to
63e5adb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this check is superfluous and can be omitted without marking the function as unsafe. The same range checks on guest memory are also performed by mem.read_obj
a few lines down, and as long as the caller validated index
to be less than queue_size
(happens in DescriptorChain::has_next
), and that the in-memory layout of the virtio queues is valid (happens in Queue::is_valid
), we are even guaranteed to read from inside the virtio queue structure. However, reading from inside the queue structure is just a functional requirement, not a safety one in Rust's sense.
I think we should still add a doc comment to the function that notes this additional requirement (e.g. callers need to make sure that index and queue layout are valid). All current callers do indeed guarantee this, so no further code changes are needed.
7c40c00
to
b099584
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4723 +/- ##
==========================================
+ Coverage 81.99% 82.00% +0.01%
==========================================
Files 254 254
Lines 31193 31195 +2
==========================================
+ Hits 25576 25581 +5
+ Misses 5617 5614 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good change. Just couple of things to fix:
- Add body to the commit. Smth like:
Remove redundant memory check in descriptor chain creation
. - Run
cargo fmt
or just manually fix: https://buildkite.com/firecracker/firecracker-pr/builds/10597#0191367a-6c71-4977-90f5-3df557e5a8a4/62-194.
b099584
to
f038f21
Compare
Remove redundant memory check in descriptor chain creation. Signed-off-by: ihciah <[email protected]>
f038f21
to
e09658a
Compare
Changes
Remove redundant memory check for
DescriptorChain::new
.Reason
Since we already validated the queue layout and desc index, there's no need to check it again.
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md
.PR Checklist
PR.
CHANGELOG.md
.TODO
s link to an issue.contribution quality standards.
rust-vmm
.