Skip to content

Allow WASI preopen file descriptors to be closed.#5828

Merged
sunfishcode merged 1 commit into
bytecodealliance:mainfrom
sunfishcode:sunfishcode/close-preopens
Feb 24, 2023
Merged

Allow WASI preopen file descriptors to be closed.#5828
sunfishcode merged 1 commit into
bytecodealliance:mainfrom
sunfishcode:sunfishcode/close-preopens

Conversation

@sunfishcode
Copy link
Copy Markdown
Member

Early on in WASI, we weren't sure whether we should allow preopens to be closed, so conservatively, we disallowed them. Among other things, this protected assumptions in wasi-libc that it can hold onto preopen file descriptors and rely on them always being open.

However now, I think it makes sense to relax this restriction. wasi-libc itself doesn't expose the preopen file descriptors, so users shouldn't ever be closing them naively, unless they have wild closes. And toolchains other than wasi-libc may want to close preopens as a way to drop priveleges once the main file handles are opened.

Early on in WASI, we weren't sure whether we should allow preopens to be
closed, so conservatively, we disallowed them. Among other things, this
protected assumptions in wasi-libc that it can hold onto preopen file
descriptors and rely on them always being open.

However now, I think it makes sense to relax this restriction. wasi-libc
itself doesn't expose the preopen file descriptors, so users shouldn't
ever be closing them naively, unless they have wild closes. And
toolchains other than wasi-libc may want to close preopens as a way to
drop priveleges once the main file handles are opened.
@sunfishcode sunfishcode requested a review from pchickey February 18, 2023 00:46
@github-actions github-actions Bot added the wasi Issues pertaining to WASI label Feb 18, 2023
@github-actions
Copy link
Copy Markdown

Subscribe to Label Action

cc @kubkon

Details This issue or pull request has been labeled: "wasi"

Thus the following users have been cc'd because of the following labels:

  • kubkon: wasi

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@sunfishcode sunfishcode added this pull request to the merge queue Feb 24, 2023
Merged via the queue into bytecodealliance:main with commit 67e2e57 Feb 24, 2023
@sunfishcode sunfishcode deleted the sunfishcode/close-preopens branch February 24, 2023 21:50
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this pull request Feb 25, 2023
This ports the test updates from bytecodealliance/wasmtime#5828 to the
preview2-prototype and implements the ability to close preopened file
descriptors.
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this pull request Feb 25, 2023
This ports the test updates from bytecodealliance/wasmtime#5828 to the
preview2-prototype and implements the ability to close preopened file
descriptors.
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this pull request Feb 27, 2023
* Allow preopen file descriptors to be closed.

This ports the test updates from bytecodealliance/wasmtime#5828 to the
preview2-prototype and implements the ability to close preopened file
descriptors.

* Fix compilation on Windows.
pchickey pushed a commit to pchickey/wasmtime that referenced this pull request May 16, 2023
* Allow preopen file descriptors to be closed.

This ports the test updates from bytecodealliance#5828 to the
preview2-prototype and implements the ability to close preopened file
descriptors.

* Fix compilation on Windows.
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