Stream: git-wasmtime

Topic: wasmtime / PR #5543 wasi: avoid buffer underflow with sha...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 06 2023 at 23:32):

abrown opened PR #5543 from wiggle-copied-reads-fix-underflow to main:

This change fixes an issue identified when using wasi-threads to perform file reads. In order to maintain Rust safety guarantees in the presence of WebAssembly shared memory, which can be modified concurrently by any of the running threads, the WASI implementations of fd_read and fd_pread were given special code paths when shared memory is detected: in these cases, the data is first read into a host-limited buffer and then subsequently copied into linear memory. The problem was that the rather-complex logic for doing this "buffer then copy" idea for multiple IO vectors could fail due to buffer underflow. If, e.g., a read was limited by the host to 64K (or even if the read returned less than the total buffer size) the UnsafeGuestSlice::copy_from_slice logic would fail, complaining that the sizes of both buffers were unequal.

This change both simplifies and fixes the logic:

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jan 09 2023 at 14:48):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 09 2023 at 14:48):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 09 2023 at 14:48):

alexcrichton created PR review comment:

I think in this case it's ok to do return Ok(0) since that's really all that can happen here anyway.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 09 2023 at 18:49):

abrown updated PR #5543 from wiggle-copied-reads-fix-underflow to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 09 2023 at 18:49):

abrown has marked PR #5543 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 09 2023 at 18:58):

abrown updated PR #5543 from wiggle-copied-reads-fix-underflow to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 09 2023 at 19:25):

abrown has enabled auto merge for PR #5543.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 09 2023 at 19:28):

abrown merged PR #5543.


Last updated: Nov 22 2024 at 17:03 UTC