-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Guard Pages Mechanism #2377
Guard Pages Mechanism #2377
Conversation
ffb9c3e
to
73063e3
Compare
076b82d
to
9d5c1ca
Compare
Have you thought into adding an integration test for this? Would be nice to have a mechanism to verify how this protects against a malicious guest kernel driver. |
There are a couple of unit tests in this PR that simulate the effect of what a malicious guest kernel would do. @berciuliviu you can further improve them by also performing read/writes that start from a valid range and overlap the guard pages. |
Understood. I will add such a test that will mimic the behaviour of test_create_guest_memory_guarded, but will instead do as you suggested, to perform operations until overlapping with the guard pages. |
9d5c1ca
to
8b14169
Compare
7ba747c
to
52eff68
Compare
This patch implements a page guarding mechanism. It will be applied at guest memory creation step and at snapshot memory restore. Signed-off-by: berciuliviu <[email protected]>
Increase Pytest coverage for Page Guarding Mechanism. Signed-off-by: berciuliviu <[email protected]>
52eff68
to
17183bb
Compare
@sandreim PTAL! |
@@ -41,6 +43,9 @@ pub use vm_memory_upstream::mmap::{check_file_offset, Error}; | |||
// The maximum number of bytes that can be read/written at a time. | |||
static MAX_ACCESS_CHUNK: usize = 4096; | |||
|
|||
// The number of guard pages per region is a multiple of 2. | |||
const GUARD_NUMBER: usize = 2; |
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.
nit: I would name this to something like GUARD_PAGE_COUNT
that is in line with what this constant does. GUARD_NUMBER
may be misleading IMO.
Reason for This PR
This PR fixes the following issue.
Description of Changes
A guard page mechanism is implemented for guest memory creation and restore from Snapshot. Every memory region in the before mentioned cases will be surrounded by a left/right border, with the dimension of a system's PAGE_SIZE.
Rust unittests are also implemented.
rust-vmm
.License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
PR Checklist
[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]
git commit -s
).unsafe
code is properly documented.firecracker/swagger.yaml
.CHANGELOG.md
.