-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Module::deserialize_open_file
#9571
base: main
Are you sure you want to change the base?
Add Module::deserialize_open_file
#9571
Conversation
Add an API to deserialize a `Module` from an already opened file. This can be useful in situations where `wasmtime` is running in a sandboxed environment with limited access to the file system. Then another process can handle opening the files and passing them to `wasmtime`.
ccc946e
to
cac7bb3
Compare
Module::from_trusted_open_file
Module::deserialize_open_file
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.
LGTM, but I am not sure I understand what you are getting at with regards to windows, so we should resolve that before merging. Thanks!
Not necessarily obvious to find but the failure is a Windows-specific one |
Yeah @alexcrichton is right - it looks like a simple Also ran the full CI on the branch now, so the previous windows failure should be good. |
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.
I think there is a writable vs readable swaparoo in the docs. AFAICT, it is readable and executable, not writable and executable, and if that is true then this is good to merge with that doc comment fixed.
If my understanding is off, and we are actually mapping as writable and executable, then I think we want to revisit what we're doing here, since that is a pretty scary widget to expose!
/// Note that the corresponding will be mapped as private writeable | ||
/// (copy-on-write) and executable. For `windows` this means the file needs | ||
/// to be opened with at least `FILE_GENERIC_READ | FILE_GENERIC_EXECUTE` | ||
/// [`access_mode`]. |
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.
Does it need to be writable? Seems like it should be (and maybe actually is?) readable and executable?
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.
In windows we create the mapping with protection PAGE_EXECUTE_WRITECOPY
which only requires the file handle was created with FILE_GENERIC_READ
and FILE_GENERIC_EXECUTE
access (docs here). It looks like write access would only be required if writes were being persisted to the file, but since we use copy-on-write it's not needed. Maybe I should add a link to these windows docs in comment for further clarity?
Add an API to deserialize a
Module
from an already opened file. This can be useful in situations wherewasmtime
is running in a sandboxed environment with limited access to the file system. Then another process can handle opening the files and passing them towasmtime
.