Skip to content
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

Fix invalid access to wasi instance handles in wasix proc_spawn #4191

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/wasix/src/state/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,12 @@ impl WasiEnv {
(memory, state, inodes)
}

pub(crate) fn get_wasi_state_and_inodes(&self) -> (&WasiState, &WasiInodes) {
let state = self.state.deref();
let inodes = &state.inodes;
(state, inodes)
}

/// Make all the commands in a [`BinaryPackage`] available to the WASI
/// instance.
///
Expand Down
3 changes: 1 addition & 2 deletions lib/wasix/src/syscalls/wasix/proc_spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ pub fn proc_spawn_internal(

// Replace the STDIO
let (stdin, stdout, stderr) = {
let (_, child_state, child_inodes) =
unsafe { child_env.get_memory_and_wasi_state_and_inodes(&new_store, 0) };
let (child_state, child_inodes) = child_env.get_wasi_state_and_inodes();
let mut conv_stdio_mode = |mode: WasiStdioMode, fd: WasiFd| -> Result<OptionFd, Errno> {
match mode {
WasiStdioMode::Piped => {
Expand Down