Stream: git-wasmtime

Topic: wasmtime / PR #13816 wasi: return NotPermitted for stream...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 04 2026 at 13:10):

SebTardif opened PR #13816 from SebTardif:fix/wasi-stream-not-permitted to bytecodealliance:main:

Summary

read_via_stream, write_via_stream, and append_via_stream returned ErrorCode::BadDescriptor when the descriptor lacked the required read/write permission. The non-stream read / write paths in the same module already return NotPermitted for the same condition.

Why this change is needed

Permission denial should use the permission-denied error code. BadDescriptor maps to a different condition (invalid/wrong kind of FD). Guests that branch on not-permitted vs bad-descriptor currently get the wrong signal when opening a stream view on a file opened without the needed access.

Change

Three sites in crates/wasi/src/p2/host/filesystem.rs:

- Err(types::ErrorCode::BadDescriptor)?;
+ Err(types::ErrorCode::NotPermitted)?;

aligned with:

// async fn read / write
if !f.perms.contains(FilePerms::READ/WRITE) {
    return Err(ErrorCode::NotPermitted.into());
}

Testing

view this post on Zulip Wasmtime GitHub notifications bot (Jul 04 2026 at 13:10):

SebTardif requested wasmtime-wasi-reviewers for a review on PR #13816.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 04 2026 at 13:10):

SebTardif requested dicej for a review on PR #13816.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 04 2026 at 15:03):

github-actions[bot] added the label wasi on PR #13816.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 03:04):

alexcrichton commented on PR #13816:

Thanks! Could you add a test for this as well?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 03:04):

alexcrichton requested alexcrichton for a review on PR #13816.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 03:04):

alexcrichton unassigned dicej from PR #13816 wasi: return NotPermitted for stream open permission failures.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 20:35):

SebTardif updated PR #13816.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 20:35):

SebTardif requested wasmtime-core-reviewers for a review on PR #13816.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 20:35):

SebTardif edited PR #13816:

Summary

read_via_stream, write_via_stream, and append_via_stream returned ErrorCode::BadDescriptor when the descriptor lacked the required read/write permission. The non-stream read / write paths in the same module already return NotPermitted for the same condition.

Why this change is needed

Permission denial should use the permission-denied error code. BadDescriptor maps to a different condition (invalid/wrong kind of FD). Guests that branch on not-permitted vs bad-descriptor currently get the wrong signal when opening a stream view on a file opened without the needed access.

Change

Three sites in crates/wasi/src/p2/host/filesystem.rs:

- Err(types::ErrorCode::BadDescriptor)?;
+ Err(types::ErrorCode::NotPermitted)?;

aligned with:

// async fn read / write
if !f.perms.contains(FilePerms::READ/WRITE) {
    return Err(ErrorCode::NotPermitted.into());
}

Testing

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 20:35):

SebTardif commented on PR #13816:

@alexcrichton Added a focused test in cbf77768a5:

It asserts ErrorCode::NotPermitted for write_via_stream / append_via_stream under a read-only preopen and for read_via_stream under a write-only preopen (while the allowed stream path still succeeds).

Verified locally with:

cargo test -p wasmtime-wasi --test all --features p2 p2_file_stream_not_permitted
# 2 passed (sync + async)

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 22:54):

:thumbs_up: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 22:54):

alexcrichton added PR #13816 wasi: return NotPermitted for stream open permission failures to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 23:19):

:check: alexcrichton merged PR #13816.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 06 2026 at 23:19):

alexcrichton removed PR #13816 wasi: return NotPermitted for stream open permission failures from the merge queue.


Last updated: Jul 29 2026 at 05:03 UTC