Skip to content
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: Fix bounds checks for dynamic heaps #8001

Merged

Conversation

saulecabrera
Copy link
Member

This commit fixes a fuzz bug in which the current implementation was incorrectly clobbering the index register of a memory access (for addition overflow check) and then using that same clobbered register to perform the memory access. The clobbered register contained the value: index + offset + access_size, which resulting in an incorrect access and consequently in an incorrect HeapOutOfBounds trap.

This bug is only reproducible when modifying Wasmtime's memory settings, forcing the heap to be treated as Dynamic.

Currently in Winch there's no easy way to have specific Wasmtime configurations, so having a filetests for this case is not straightforward. I've opted to add an integration test, in which it's easier to configure Wasmtime.

Note that the tests/all/winch.rs file is temporary, and the plan is to execute all the other integration tests with Winch at some point. In the case of memory.rs, that will be once Winch supports memory64 hoping to reduce the amount of code needed in order to integrate Winch.

This commit fixes a fuzz bug in which the current implementation was incorrectly cloberring the index register of a memory access (for addition overflow check) and then using that same clobbered register to perform the memory access. The clobbered register contained the value: `index + offset + access_size`, which resulting in an incorrect access and consequently in an incorrect `HeapOutOfBounds` trap.

This bug is only reproducible when modifying Wasmtime's memory settings, forcing the heap to be treated as `Dynamic`.

Currently in Winch there's no easy way to have specific Wasmtime configurations, so having a filetests for this case is not straightforward. I've opted to add an integration test, in which it's easier to configure Wasmtime.

Note that the `tests/all/winch.rs`  file is temporary, and the plan is to execute all the other integration tests with Winch at some point. In the case of `memory.rs`, that will be once Winch supports `memory64` hoping to reduce the amount of code needed in order to integrate Winch.
@saulecabrera saulecabrera requested review from a team as code owners February 27, 2024 18:27
@saulecabrera saulecabrera requested review from fitzgen and elliottt and removed request for a team February 27, 2024 18:27
@saulecabrera saulecabrera added this pull request to the merge queue Feb 27, 2024
Merged via the queue into bytecodealliance:main with commit e341557 Feb 27, 2024
19 checks passed
@saulecabrera saulecabrera deleted the winch-fix-dynamic-heap-bounds branch February 27, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants