Fix exec module loading via 3i: marshal loader buffers through cage memory - #1364
Closed
rishabhBudhouliya wants to merge 2 commits into
Closed
Fix exec module loading via 3i: marshal loader buffers through cage memory#1364rishabhBudhouliya wants to merge 2 commits into
rishabhBudhouliya wants to merge 2 commits into
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
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.
Summary
Ports PR #1285 (exec loads its target through 3i instead of host file APIs) onto
enarx-7-13and fixes the bug that made it fail under grates.The problem: the exec loader passed pointers to runtime heap buffers (the path string and the read buffer) into
make_syscall. 3i validates every pointer against the calling cage's vmmap, so these pointers failed validation. Under the IMFS grate, every exec path silently resolved to the root directory and read returned EBADF.The fix: exec now mmaps a small scratch region inside the exec-ing cage's own linear memory (same pattern as
early_init_stack), writes the path there, reads the module in chunks through it, and unmaps it when done (also on error paths, via a Drop guard). Pointer args are passed in the same pre-translated form the wasmtime trampoline uses for guest syscalls.Why this design:
Related issues
Part of #1001. Applies the approach of #1285 on the enarx branch.
Testing
On lind server 3 under real SGX with the IMFS grate. All three cases failed instantly with EBADF before this change:
Compatibility and security impact
[instrument]eprintln debug lines from this investigation. They should be stripped before any of this moves toward main.Checklist