-
Notifications
You must be signed in to change notification settings - Fork 133
Added capability to load extra blob data in sandbox #605
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
f46ffef
to
e46c2a8
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.
The PR comment states that the this is a non-breaking change, but the rename GuestBinary -> GuestBlob is breaking, right? Also I do think the renaming is not intuitive for users who want to load a guest binary, when it's now called GuestBlob
Not strictly related to your PR, but I think we should consider not allowing passing blobs/binaries by "path", which would force the consumers to do their own reading of files, etc, and instead only take slices of u8.
I haven't fully thought about it, but maybe Uninitialized::new
should take a trait instead?
IIRC, @simongdavies had an idea where the host could share host memory with the VM by adding pages to the VM's page table. Would something like that help in this case? |
On the breaking-change point, you're right. Guess what I meant to say is that you don't necessarily have to pass a
If so, I can change
It does currently take a trait: |
What do you think about letting pub trait GuestEnvironment {
/// Get the guest binary
fn guest_binary(&self) -> &[u8];
/// Get optional memory blobs
fn blobs(&self) -> Option<&[&[u8]]>;
} Then we could implement it for exisiting GuestBinary, and also a new GuestBinaryWithBlob, etc, etc. |
I think I like |
@simongdavies @jprendes @dblnz @andreiltd @syntactically, any opinions on the API of this PR? |
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.
Looks good just a few questions
I don't recall what that might have been, but I think if @danbugs takes up my feedback about allowing the data to have RWX flags associated with it then if its R we could do an optimisation where its only allocated in the host once, that would require us to change the way we bounds check though so I think out of scope here. We also talked about allowing a user to pass an vector of (address,len) into a sandbox for mapping, that may be a better way to do something like this, and it may fit better in a configuration than as a argument to the new function |
I think this all stemmed from us having in-proc and more specifically loadlib support in Windows, I think you are correct, I don't think we need it any longer ,not sure if now is the right time though... |
I quite like it as it is but not really that fussed either way, eventually we should bury all this behind a builder, that might be the right time to get rid of the paths |
7371ebe
to
96749f1
Compare
Added configurable flags to the new mem region 👍 |
#614 ~ made an issue for this, @ludfjig / @simongdavies |
eace8a2
to
fcddae7
Compare
The GuestEnvironment struct contains two blobs of data. One identifiable as a guest binary, and one undifferentiated guest blob. This GuestEnvironment is now used to create a new sandbox in place of just a guest binary. There are TryFrom impls to be able to convert from a guest binary to a GuestEnvironment, so this isn't a breaking change. Signed-off-by: danbugs <[email protected]>
+ if guest blob is provided, we now write it to shared mem when creating a sandbox Signed-off-by: danbugs <[email protected]>
W/ this, now the guest can access that memory region. Signed-off-by: danbugs <[email protected]>
… data + modified guest and guest_bin libs for it too Signed-off-by: danbugs <[email protected]>
This PR contains the following changes:
(1) Made a non-breaking change to the signature of the
UninitializedSandbox::new(...)
function. Now, instead of aGuestBinary
, it takes aGuestEnvironment
, which contains the usual binary + optional blob data.(2) Created new user memory region to store the extra blob data and added some extra config options for it.
(3) Added info of the new memory region to the PEB.
(4) Added tests verifying added blob data.
Reviewing commit-by-commit might be best 👍