-
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
winch: Sync registers and locals before fuel check #9554
winch: Sync registers and locals before fuel check #9554
Conversation
This commit fixes a fuzz bug in which the stack was misaligned when calling the out-of-fuel builtin function. The misalignment was introduced by a erroneous handling of the the control flow merge introduced by the fuel check conditional. In general, prior to every branch emission, a spill to memory is needed to avoid issues at the control flow merge. Note that we don't have many cases like this one in Winch's codebase (3 in total), however as a follow-up, it's probably worth considering introducing a stronger abstraction around branching to ensure that this case is handled whenever an arbitrary branch needs to be introduced. This change solely focuses on the fix and does not introduce any refactoring. I plan to follow-up with investigating a better branching strategy, since we would need to introduce a similar pattern for epoch handling. I used `wasm-tools shink` to shrink the original program, which I decided to add as part of an integration test.
Subscribe to Label Action
This issue or pull request has been labeled: "winch"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
@saulecabrera would you be ok backporting this to the release-27 branch? If you're busy I'm happy to take that on myself |
@alexcrichton I've opened #9564. Just to confirm, since 27 is not released yet, there's nothing to follow-up on after the backport lands, right? |
Indeed, and thanks! |
This commit fixes a fuzz bug in which the stack was misaligned when calling the out-of-fuel builtin function.
The misalignment was introduced by a erroneous handling of the the control flow merge introduced by the fuel check conditional. In general, prior to every branch emission, a spill to memory is needed to avoid issues at the control flow merge.
Note that we don't have many cases like this one in Winch's codebase (3 in total), however as a follow-up, it's probably worth considering introducing a stronger abstraction around branching to ensure that this case is handled whenever an arbitrary branch needs to be introduced. This change solely focuses on the fix and does not introduce any refactoring. I plan to follow-up with investigating a better branching strategy, since we would need to introduce a similar pattern for epoch handling.
I used
wasm-tools shink
to shrink the original program, which I decided to add as part of an integration test.