alexcrichton opened PR #12949 from alexcrichton:x64-fix-amode-offset-overflow to bytecodealliance:main:
This commit fixes an issue in the x64 backend of Cranelift where the
Amode::offsetmethod contained unchecked arithmetic meaning that it could possibly overflow. This in turn could lead to a miscompile of loading/storing 128-bit integers where this method is used to generate anAmodethat is 8 bytes beyond the based address to load the upper bits. This miscompile isn't reachable from WebAssembly but is nonetheless still a good bugfix to have for Cranelift.The fix here is to switch the
Amode::offsetmethod to being fallible, returningNoneon overflow. This then propagates up into ISLE where theamode_offsethelper now has a separate case for when the addition fails, usingleato generate a register with an address in it. This then subsequently also needed fixing for variousAtomic128*operations where instead of storing just a singleSyntheticAmodethey now store two, one for the address of the low bits and one for the address of the high bits.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested fitzgen for a review on PR #12949.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #12949.
cfallin submitted PR review:
Thanks!
cfallin commented on PR #12949:
(
cranelift-codegenunit tests for inst emission need updates wrt the new field I think)
alexcrichton updated PR #12949.
alexcrichton commented on PR #12949:
@cfallin mind double-checking the most recent commit? Avoiding inflating
Insttook a bit of finesse
cfallin submitted PR review:
All the glue for the inst-arg boxing looks right to me; thanks!
alexcrichton updated PR #12949.
alexcrichton has enabled auto merge for PR #12949.
alexcrichton added PR #12949 x64: Fix possible overflow in Amode::offset to the merge queue
alexcrichton merged PR #12949.
alexcrichton removed PR #12949 x64: Fix possible overflow in Amode::offset from the merge queue
Last updated: Apr 12 2026 at 23:10 UTC