Commit Graph

1124 Commits

Author SHA1 Message Date
Pat Hickey
82edae32b7 readlink 2020-12-18 11:33:28 -08:00
Pat Hickey
f6afd4c41c test-programs: sandbox escape is an EPERM now, not an ENOTCAPABLE 2020-12-17 18:12:29 -08:00
Pat Hickey
d8720cffe8 unexpected io error: do our best based on e.kind() 2020-12-17 18:12:15 -08:00
Pat Hickey
f9ff97aac1 virt pipes: return concrete errors, best effort at flags and filestat 2020-12-17 17:48:46 -08:00
Pat Hickey
4c3c9a9ecb Filestat: make times optional, default to 0 at wasi interface
this is DRY
2020-12-17 17:29:35 -08:00
Pat Hickey
8ac688287e fixup dir/file caps into rights 2020-12-17 17:29:00 -08:00
Pat Hickey
df0218c086 make get_filestat work
up to 16 tests passing!
2020-12-16 17:54:17 -08:00
Pat Hickey
23b5689a5f fix file rights 2020-12-16 17:19:27 -08:00
Pat Hickey
8777194f0d always open files read if not write
and if creating a file, open it write.
2020-12-16 16:07:23 -08:00
Pat Hickey
af8bdf8933 table: borrow entry immutably or mutably 2020-12-16 15:55:30 -08:00
Pat Hickey
dbe0f4f284 Revert "dangling_fd test: open with either READ or CREAT|WRITE"
fix for behavior in wasi-c2 coming in next commit

This reverts commit 789eec3827.
2020-12-16 15:54:46 -08:00
Pat Hickey
789eec3827 dangling_fd test: open with either READ or CREAT|WRITE
neither READ nor WRITE is an error
2020-12-16 15:16:14 -08:00
Pat Hickey
27ddbda829 preopens with Caps::all, implement create, remove dir, remove file 2020-12-16 15:15:48 -08:00
Pat Hickey
c0461ca170 redesign how caps fit into entries! 2020-12-15 18:09:36 -08:00
Pat Hickey
b5852bf5ff open_dir can never create a dir 2020-12-15 16:44:03 -08:00
Pat Hickey
04805fcc5f pass a test, dubiously 2020-12-14 19:48:30 -08:00
Pat Hickey
c16e731455 get rid of linker Rc cycle, and add debug info to test programs 2020-12-14 17:15:03 -08:00
Pat Hickey
7ec9aac39f Merge remote-tracking branch 'origin/main' into pch/wasi_common_cap_std 2020-12-14 16:17:10 -08:00
Alex Crichton
2d7c2fba5f Update wasm-smith (#2509)
Brings in a few bug fixes for generating module-linking modules
2020-12-14 13:39:38 -06:00
Nick Fitzgerald
ed971fcfcc Merge pull request #2505 from alexcrichton/fix-reserve-bug
Fix a memory reservation bug in `reserve_modules`
2020-12-14 10:12:46 -08:00
Alex Crichton
42adeba65d Fix fuzzer expectation about valid modules
Recent changes to fuzzers made expectations more strict about handling
errors while fuzzing, but this erroneously changed a module compilation
step to always assume that the input wasm is valid. Instead a flag is
now passed through indicating whether the wasm blob is known valid or
invalid, and only if compilation fails and it's known valid do we panic.
2020-12-14 08:31:46 -08:00
Alex Crichton
c83dee07b7 Fix a memory reservation bug in reserve_modules
This method attempted to reserve space in the `results` list of final
modules. Unfortunately `results.reserve(nmodules)` isn't enough here
because this can be called many times before a module is actually
finished and pushed onto the vector. The attempted logic to work around
this was buggy, however, and would simply trigger geometric growth on
every single reservation because it erroneously assumed that a
reservation would be exactly met.

This is fixed by avoiding looking at the vector's capacity and instead
keeping track of modules-to-be in a side field. This is the incremented
and passed to `reserve` as it represents the number of modules that will
eventually make their way into the result vector.
2020-12-14 07:57:47 -08:00
Pat Hickey
1b8f9fd377 use virtual stdio
which works except for the lifetime issues, i think the trap still holds
an Rc to the store?
2020-12-11 18:22:13 -08:00
Pat Hickey
0572b40f58 port read and write pipes in 2020-12-11 17:54:32 -08:00
Pat Hickey
759455192b test-programs: learn how to preopen a dir again 2020-12-11 16:38:55 -08:00
Pat Hickey
30d49d122c add preopened_dir to builder 2020-12-11 16:38:44 -08:00
Pat Hickey
dfcdbfd0fe test-programs: no longer test virtfs separately
wasi-c2 does not have a virtfs yet, and when it does we'll design a
better test harness

also fix prestat get: i was reporting the wrong error
2020-12-11 15:51:14 -08:00
Pat Hickey
61f97a3e92 trap on wasi_proc_exit 2020-12-11 15:37:04 -08:00
Pat Hickey
d586574b1f port in args and env. slightly different style
building up a bunch of deferred errors in the CtxBuilder sucks. so does
reporting errors right away. Idk what to do here?
2020-12-11 15:33:59 -08:00
Pat Hickey
aef8be560f test-programs: use wasi-c2 instead of wasmtime 2020-12-11 15:00:58 -08:00
Pat Hickey
22db10e643 add wasmtime adapter and stdio wrappers
the stdio wrappers will not work on windows, but thats a whole other can
of worms anyway
2020-12-11 15:00:33 -08:00
Pat Hickey
73058658f4 switch to cap-fs-ext::MetadataExt 2020-12-11 12:14:09 -08:00
Dan Gohman
1d90c329b4 Remove an unused variable. 2020-12-11 10:52:54 -08:00
Dan Gohman
88a073eac3 rustfmt 2020-12-11 10:52:54 -08:00
Dan Gohman
c3f0471ff2 Fix the return value from wasi-common's fd_readdir.
`fd_readdir` returns a "bufused" value, which indicates the number of
bytes read into the buffer. WASI libc expects this value to be equal
to the size of the buffer if the end of the directory has not yet
been scanned.

Previously, wasi-common's `fd_readdir` was writing as many complete
entries as it could fit and then stopping, but this meant it was
returning size less than the buffer size even when the directory had
more entries. This patch makes it continue writing up until the end
of the buffer, and return that number of bytes, to let WASI libc
know that there's more to be read.

Fixes #2493.
2020-12-11 10:52:54 -08:00
Alex Crichton
25000afe69 Enable fuzzing the module linking implementation
This commit updates all the wasm-tools crates that we use and enables
fuzzing of the module linking proposal in our various fuzz targets. This
also refactors some of the dummy value generation logic to not be
fallible and to always succeed, the thinking being that we don't want to
accidentally hide errors while fuzzing. Additionally instantiation is
only allowed to fail with a `Trap`, other failure reasons are unwrapped.
2020-12-11 08:36:52 -08:00
Pat Hickey
47f3a6bcb9 sketchy implementation of readdir 2020-12-10 17:31:21 -08:00
Pat Hickey
03c92de5aa stub out set_oflags for unix i guess?
what do we do about unsupported stuff like that? silently return OK?
2020-12-10 15:37:02 -08:00
Pat Hickey
cdb642b3d6 do cfg right 2020-12-10 15:07:18 -08:00
Pat Hickey
4dd1836704 windows nightly can give us filestat info 2020-12-10 14:50:55 -08:00
Pat Hickey
20eb66beab fixes to system-interface, use fs-set-times 2020-12-10 12:06:36 -08:00
Alex Crichton
e09b9400f8 Restrict threads spawned during fuzzing (#2485)
I was having limited success fuzzing locally because apparently the
fuzzer was spawning too many threads. Looking into it that indeed
appears to be the case! The threads which time out runtime of wasm only
exit after the sleep has completely finished, meaning that if we execute
a ton of wasm that exits quickly each run will generate a sleeping thread.

This commit fixes the issue by using some synchronization to ensure the
sleeping thread exits when our fuzzed run also exits.
2020-12-09 10:34:37 -06:00
Pat Hickey
229474d6e0 sketchy path_open 2020-12-07 18:21:09 -08:00
Pat Hickey
5590b27fdf impl WasiFile for cap_std::fs::File 2020-12-07 17:12:08 -08:00
Andrew Brown
2c765c18c2 Update spec tests 2020-12-07 10:59:55 -08:00
Andrew Brown
f1025322fa Update wasmparser to 0.69.2 2020-12-07 10:59:55 -08:00
Andrew Brown
fc752efa89 Fix incorrect arithmetic NaN check and document 2020-12-04 14:44:43 -08:00
Andrew Brown
651f405220 Print WAST assertion failures in a hexadecimal pattern format
Fixes #1681.
2020-12-04 14:44:43 -08:00
Andrew Brown
d07fffeb41 Use AlexNet for wasi-nn example (#2474) 2020-12-04 09:07:19 -06:00
Pat Hickey
05ecdbfa96 change the preopen strategy again, implement more calls 2020-12-03 17:12:21 -08:00