[36.0.x] Vendor cap-std/cap-primitives into wasmtime-wasi - #14224
Open
alexcrichton wants to merge 3 commits into
Open
[36.0.x] Vendor cap-std/cap-primitives into wasmtime-wasi#14224alexcrichton wants to merge 3 commits into
wasmtime-wasi#14224alexcrichton wants to merge 3 commits into
Conversation
Copy the entire contents of this crate into `crates/wasi/src/filesystem/primitives` for future modifications to get it building.
This commit adjust the wasmtime 36.0.0 state of the `wasmtime-wasi` crate to use the vendored primitives in the prior commit. This is much more involved than just a cherry-pick because the internals of `wasmtime-wasi` have greatly changed since the 36.0.0 release, namely: * WASIp3 support was added and shared code between p2/p3 was refactored to its own module. * The `cap-std` dependency was largely removed which vendored some fringe platform-specific code from that and surrounding crates. These major changes aren't present on the 36.0.0 branch, and additionally the public types of `wasmtime-wasi` contain more `cap_std` types than before. To handle all of this the commit here leaves the public type definitions as-is but helpers internally all switch to using the previously-vendored primitives. This involved vendoring more code from the `main` branch and is a bit invasive, but this is all necessary to sever dependencies with the `cap-std` crates.
alexcrichton
requested review from
fitzgen and
pchickey
and removed request for
a team
August 28, 2026 18:20
pchickey
approved these changes
Aug 28, 2026
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.
This is the equivalent of #14219 for the 36.0.x release branch which we'll be supporting for another year. The goal here is to ensure that fixing security issues in the filesystem sandbox is in theory a purely local change within Wasmtime like it would be on
mainto avoid having to both changemainand additionally change publishedcap-stdcrates.The backport here is much more involved than just cherry-picking #14219 to this branch. As described in the second commit this historical version of Wasmtime is missing major refactorings such as moving away from
cap-stdand the refactoring of filesystem internals across wasip2 and wasip3. This means that while theprimitivesdirectory is directly cherry-picked from #14219 the rest of this is basically hand-written. This hand-vendors more platform-specific modules frommainand wires everything up.To add another wrinkle to all of this the
cap-stdcrate is visible in the public API ofwasmtime-wasito a greater degree than it is on main. For example theDescriptortype hasfileanddirmethods which expose the underlyingFileandDirstructures ofwasmtime-wasiwhich havepubfields which arecap_std::fs::{File,Dir}types. It would be a semver-breaking change, technically, to change these tostd::fs::Fileas is present onmain. To handle this those parts are left as-is but all operations are done internally asstd::fs::File. The intention is that all sandboxing logic lives within the localprimitivesmodule.