Fix native filesystem, memory, environment and CLI boundaries - #803
Merged
LunaStev merged 2 commits intoSep 27, 2026
Merged
Conversation
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
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
TRUNCworks withoutCREATand append handles write at EOF after seeks or duplication. Obtain the restricted append handle before truncation so a duplication failure preserves existing data.fstatfrom native handle metadata and reject unsupported handle types. Honor supported anonymous privatemmapprotections and reject unsupported flags/protections before allocating.Motivation
These paths could silently overwrite append data, retain data after a requested truncation, report invented file metadata, grant unrequested memory access, or return truncated environment values as successful reads.
Fixes #527
Fixes #524
Fixes #784
Fixes #511
Fixes #400
Target and compatibility impact
mmapsupports anonymous private no-access, read-only and read/write mappings. Write-only and unknown protection/flag combinations return null.-ENOSPCinstead of a successful partial source;env_getgrows and retries. New environment error constants distinguish read, incomplete-source and allocation failures. Other OS error domains are not treated as LinuxENOSPC.Validation
Local checks used LLVM 21 and checkout std:
LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo test --locked --jobs 2 --no-default-features --features llvm-target-core64 --test native_boundaries --test stabilization_17: 6 new boundary tests and 9 existing stabilization tests passed. The existing opt-in WASM runtime test was gated off.LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo test --locked --jobs 2 --no-default-features --features llvm-target-core64 --test codegen_regressions --test frontend_regressions --lib: library tests passed (7); codegen passed 89/90 in the restricted sandbox. The TCP test failed there and passed when rerun individually with local socket permission. Because Cargo stopped after that suite,--test frontend_regressionswas run separately: 16 passed.LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo test --locked --jobs 2 --no-default-features --features llvm-target-core64 --test codegen_regressions async_tasks_suspend_resume_cancel_and_exchange_tcp_data -- --exact: passed outside the restricted sandbox.LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo test --locked --jobs 2 --test native_boundaries environment_provider_cross_target_objects: passed with default backends, including LoongArch64 and WASI; 20 O0/O2 objects across 10 targets.LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo clippy --locked --jobs 2 --lib --bin wavec --test native_boundaries -- -D warnings,cargo fmt --all -- --check,bash tools/check_std_policy.sh, andgit diff --check: passed.The new suite runs real Linux controlled environments and O0/O2 Win32 API mocks, including failure cleanup. Native Windows fixtures cross-compile for amd64/ARM64; actual Windows execution is pending CI.
Checklist
Signed-off-byline.std/.