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

consistient WASI preview1 rights reporting #6784

Merged
merged 2 commits into from
Aug 2, 2023

Conversation

pchickey
Copy link
Contributor

We have three preview1 implementations in tree:

  • wasi-common
  • wasi-preview1-component-adapter
  • wasmtime-wasi::preview2::preview1

This PR makes all of them report the exact same set of rights for directories.

wasi-libc based userlands (e.g. wasi-sdk, tinygo, some parts of rust std, and others!) will sometimes check whether they have a preview1 Right to perform an import function call, and return early if they do not.

Last attempt at adjusting how we report Rights #6463
hard-coded the set of rights in wasi-common. That PR also added a wasi-test path_open_preopen that was intended to check whether wasi-libc's expectations were met. This test focused on the bug report we had wasi-libc around opening directories, and short of testing for the full expected set or rights.

We got a bug report on zulip that tinygo, which uses wasi-libc, failed in the go call os.Create: https://bytecodealliance.zulipchat.com/#narrow/stream/217126-wasmtime/topic/Problem.20with.20WasiCtxBuilder.2Epush_preopened_dir.20for.20component . It appeared this was getting rejected in wasi-libc, using the rights reported from the wasi-preview1-component-adapter.

To avoid chasing these individual wasi-libc behaviors much further, I decided to add the expectation of the set of rights to path_open_preopen, and fix wasi-preview1-component-adapter and wasmtime-wasi::preview2::preview1 to always report those rights. This does mean duplicating that list of rights in a few more places in the source code, but theres no good way to do code sharing among these crates because the constants are coming from different crates/binding generators across these projects.

I'd love for this to be the last time we have to kick the Rights can down the road. However, I'm now paranoid that, even with directories taken care of, we will run into the a similar problem with wasi-libc's expectation of file rights. I believe the behavior for file rights is consistent across all three implementations, so since we haven't gotten any file related bug reports since #6463 I am hopeful we have it right everywhere.

@pchickey pchickey requested a review from a team as a code owner July 28, 2023 19:33
@pchickey pchickey requested review from alexcrichton, sunfishcode, a team and jameysharp and removed request for a team, alexcrichton and jameysharp July 28, 2023 19:33
@github-actions github-actions bot added the wasi Issues pertaining to WASI label Jul 28, 2023
@alexcrichton alexcrichton added this pull request to the merge queue Aug 2, 2023
Merged via the queue into main with commit 6eb5898 Aug 2, 2023
21 checks passed
@alexcrichton alexcrichton deleted the pch/consistient_rights_reporting branch August 2, 2023 11:03
geekbeast pushed a commit to geekbeast/wasmtime that referenced this pull request Aug 6, 2023
… feature/preview2

* 'feature/preview2' of github.com:geekbeast/wasmtime:
  Change preview2 builder methods to use `&mut self` (bytecodealliance#6770)
  Add a bindgen test that exercises using error types from a different interface (bytecodealliance#6802)
  Resolve trappable error types with fully qualified package paths (bytecodealliance#6795)
  Update the dev-dependency for wit-bindgen to 0.9.0 (bytecodealliance#6800)
  Fix incorrect sample code in documentation (bytecodealliance#6796) (bytecodealliance#6797)
  Update preview1 to trap on misaligned pointers (bytecodealliance#6776)
  Fix posix-signals-on-macos on aarch64-apple-darwin (bytecodealliance#6793)
  consistient WASI preview1 rights reporting (bytecodealliance#6784)
  Wasmtime: Introduce `{Module,Component}::resources_required` (bytecodealliance#6789)
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Aug 18, 2023
* wasi-tests path_open_preopen: hard-code minimum set of required rights

* preview1 adapters: return exact same set of rights as wasi-common
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants