Repository navigation
Description
Problem
The WASI filesystem access provider ignores its mode argument. Any successful filestat lookup makes even an invalid mode such as 1024 succeed, and requested access rights are not established.
Starting points: std/sys/wasm/fs.wave.
Reproduction
Tested at 6257ba3eb4b9f1ab6c247a920c6e0c4b5d699331 on Linux amd64 with LLVM 21.1.8 and a compiler built from that checkout. Build it with LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo build --locked --jobs 2. Node.js 22.22.1 and wasm-ld were used. This is an executed Wave WASI module with controlled host imports, not an assertion about how frequently a production host returns these values.
For a self-contained test against this checkout's std, create a temporary alias (leaving installed std unchanged):
python3 - <<'PYSETUP'
from pathlib import Path
import shutil
p = Path('/tmp/wave-issue-std')
shutil.copytree('std', p, dirs_exist_ok=True)
for f in p.rglob('*.wave'):
f.write_text(f.read_text().replace('"std::', '"checkout_std::'))
PYSETUPSave as repro.wave:
import("checkout_std::sys::fs")::{access};
pub fun audit() -> i64 { return access("anything", 1024); }
fun main() -> i32 { return 0; }
target/debug/wavec build repro.wave --dep checkout_std=/tmp/wave-issue-std --target wasm32-wasip1 -O0 --emit=obj --out-dir /tmp/wave-issue-wasi
wasm-ld --no-entry --export=audit --export-memory /tmp/wave-issue-wasi/repro.o -o /tmp/wave-issue-wasi/test.wasmSave as repro.cjs and run node repro.cjs:
const fs = require('fs');
(async () => {
const module = await WebAssembly.compile(fs.readFileSync('/tmp/wave-issue-wasi/test.wasm'));
const imports = {}; let instance; let calls = 0;
for (const i of WebAssembly.Module.imports(module)) {
imports[i.module] ??= {};
imports[i.module][i.name] = () => 0;
}
// The controlled path_filestat_get import reports success.
// This isolates mode validation from filesystem lookup failures.
instance = await WebAssembly.instantiate(module, imports);
console.log(String(instance.exports.audit()), 'read calls:', calls);
})().catch(e => { console.error(e); process.exit(1); });Observed: 0 read calls: 0, accepting unsupported mode bits. Repeat compilation with -O2; the same behavior was observed.
The official WASI Preview 1 header defines EINTR as 27 and timestamps as u64 nanoseconds.
Scope
Distinguish existence checks, invalid mode bits and permission/capability requests. Do not claim access that WASI capabilities cannot establish. Windows access issues #705/#528 concern a different provider.
Difficulty: medium.
Completion criteria
- Reject invalid mode bits rather than returning success.
- Cover F_OK and every supported mode/combination against granted and missing capabilities.
- Return a clear unsupported/error result when a requested check cannot be implemented.
Design decision needed: Agree on R_OK/W_OK/X_OK semantics under WASI capabilities, including which requests must be unsupported.
Please mention @LunaStev to discuss the design before starting implementation.
Activity