-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x64: Incorrect out-of-bounds access reported for a misaligned float load #4890
Comments
It seems like we want a stronger condition in wasmtime/cranelift/codegen/src/isa/x64/lower/isle.rs Lines 169 to 175 in 2986f6b
|
I sort of suspect that we will find most loads encountered by |
I was just experimenting with that fix and was going to suggest it :) I'll make a PR! |
In cg_clif we do almost always know an alignment bigger than 1. |
Fair enough; we can eventually look at adding this back, while respecting alignment, but IMHO we should fix the fuzzbug first in the most straightforward way, especially given we want to cherry-pick this to the 1.0 branch too :-) |
Here's another option: in wasmtime/cranelift/codegen/src/isa/x64/lower.rs Lines 107 to 111 in 2986f6b
|
We could also pass a flag to |
Possibly, yeah, though it's less obviously clear to me that this covers all cases (e.g. what if some lowering were to somehow load an integer-typed value into an XMM register?). The proximate cause here is that loads into XMM registers merged into SSE instructions need to be aligned, so I'd prefer to take the more risk-averse option for the initial fix and turn that path off altogether, I think... |
For now, never merging the loads is obviously correct, and we can always revisit this later :) |
Do not merge loads for xmm registers, as alignment requirements currently aren't satisfied with clif lowered from wasm. Fixes #4890
Perhaps there should be an issue to revisit this later? @elliottt brought up what seemed to me like good avenues for fixing this. |
@elliottt also would you be up for backporting this to the release-1.0.0 branch? If not no worries and I can do that as well. |
Absolutely, I'll make a PR today and send it to you for review. |
Do not merge loads for xmm registers, as alignment requirements currently aren't satisfied with clif lowered from wasm. Fixes bytecodealliance#4890
This input module:
yields:
but the trap reported here is incorrect because there is no out-of-bounds memory access in this module. Instead what's happening is that in the compile function:
The instruction at 0x21 is segfaulting due to a misaligned address. The segfault is also registered as a trap point in Wasmtime since I believe this is a folding of the
f32.load
into thef32.copysign
and so this could also segfault due to an out-of-bounds memory access.Bisection reveals that this issue become a segfault in #4730 and then became a trap in #4790 (cc @elliottt). We'll want to be sure to backport the fix for this to the release-1.0.0 branch as well.
The text was updated successfully, but these errors were encountered: