fix: remove rightsBase write check from fdOpen permission guard#1431
Open
luchiniatwork wants to merge 1 commit intorivet-dev:mainfrom
Open
fix: remove rightsBase write check from fdOpen permission guard#1431luchiniatwork wants to merge 1 commit intorivet-dev:mainfrom
luchiniatwork wants to merge 1 commit intorivet-dev:mainfrom
Conversation
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.
Summary
WASM commands with
read-onlypermission tier (ls,find,stat,cat, etc.) fail with EACCES when opening directories for reading.Problem
The
fdOpenpermission guard inpackages/posix/src/kernel-worker.tstreatsRIGHT_FD_WRITEinrightsBaseas write intent:In WASI,
rightsBaseis a capability advertisement, not an intent declaration. WASI runtimes (specifically Rust's wasi-libc used by uutils-coreutils) routinely request broad rights includingRIGHT_FD_WRITEeven for purely read-only operations likeopendir(). The runtime requests the maximum set of capabilities the file descriptor could need, and the host is expected to narrow them — not reject the open entirely.Fix
Remove
|| wantsWritefrom thehasWriteIntentcondition. Actual write intent is already correctly captured by:oflags & 0x1—O_CREAT(create file)oflags & 0x8—O_TRUNC(truncate file)fdflags & 0x1—O_APPEND(append mode)Why this is safe
Write restrictions are independently enforced at two other layers:
fdOpenRPC handler indriver.tsvalidates permissions when the open call reaches the kernel.The
wantsRead/wantsWritevariables remain in the function — they are used downstream for mapping WASI rights to POSIX open flags (O_RDONLY/O_WRONLY/O_RDWR), which is a flag translation step, not a permission check.EOF
)