Stream: git-wasmtime

Topic: wasmtime / PR #15291 wasi-nn: decode WinML input tensors ...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2026 at 15:29):

netliomax25-code opened PR #15291 from netliomax25-code:wasi-nn-winml-tensor-decode to bytecodealliance:main:

to_inspectable in the WinML backend turns an input tensor's Vec<u8> into &[f32] / &[i64] with slice::from_raw_parts(tensor.data.as_ptr().cast::<T>(), ...). A Vec<u8> only guarantees 1-byte alignment, so building that slice is undefined behavior unless the allocator happens to hand back a suitably aligned block. The check_alignment call after it can't catch a misaligned buffer: it runs align_to::<T>() on a slice that is already &[T], so prefix and suffix are always empty, and the UB has already happened by then anyway.

Running the same construct under Miri with -Zmiri-symbolic-alignment-check reports constructing invalid value of type &[f32]: encountered an unaligned reference (required 4 byte alignment but found 1).

The elements are now decoded with chunks_exact + from_le_bytes, the same encoding to_tensor and the ONNX backend's bytes_to_f32_vec already use, so the unsafe blocks and check_alignment go away. Values are unchanged on Windows (little-endian), and a trailing partial element is still ignored as before. wasi-nn is tier 3, so as far as I can tell this is not a security issue under Wasmtime's policy.

Verification: cargo check and cargo clippy of wasmtime-wasi-nn (lib + tests, default features, -D warnings) for x86_64-pc-windows-msvc are clean, rustfmt is clean, and the new helper passes the same Miri run. I could only cross-check from a non-Windows machine, so the existing fp16/fp32/i64 round-trip unit tests in winml.rs were compiled but not executed here; CI's Windows job should cover them.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2026 at 15:29):

netliomax25-code removed the review request for wasmtime-wasi-reviewers from PR #15291.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2026 at 15:29):

netliomax25-code requested rvolosatovs for a review on PR #15291.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2026 at 15:29):

netliomax25-code requested wasmtime-wasi-reviewers for a review on PR #15291.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2026 at 17:01):

alexcrichton removed the review request for rvolosatovs from PR #15291.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2026 at 17:01):

alexcrichton commented on PR #15291:

cc @rahulchaphalkar @jlb6740


Last updated: Nov 19 2026 at 20:05 UTC