diff --git a/crates/wasmtime/src/runtime/memory.rs b/crates/wasmtime/src/runtime/memory.rs index 3955d541c71b..5f4418818785 100644 --- a/crates/wasmtime/src/runtime/memory.rs +++ b/crates/wasmtime/src/runtime/memory.rs @@ -738,6 +738,14 @@ impl Memory { /// guard page. Additionally the safety concerns explained in ['Memory'], for /// accessing the memory apply here as well. /// +/// The value returned by [`LinearMemory::byte_size`] must be at least the +/// `minimum` size the memory was created with, must be at least `new_size` +/// after a successful [`LinearMemory::grow_to`], and must never decrease. +/// At least that many bytes starting at [`LinearMemory::as_ptr`] must be +/// valid to read and write. Compiled WebAssembly code relies on these +/// properties when performing bounds checks, so violating them can lead to +/// out-of-bounds memory accesses. +/// /// Note that this is a relatively advanced feature and it is recommended to be /// familiar with wasmtime runtime code to use it. pub unsafe trait LinearMemory: Send + Sync + 'static {