Skip to content

winch: Fix bounds checks for dynamic heaps#8001

Merged
saulecabrera merged 2 commits into
bytecodealliance:mainfrom
saulecabrera:winch-fix-dynamic-heap-bounds
Feb 27, 2024
Merged

winch: Fix bounds checks for dynamic heaps#8001
saulecabrera merged 2 commits into
bytecodealliance:mainfrom
saulecabrera:winch-fix-dynamic-heap-bounds

Conversation

@saulecabrera
Copy link
Copy Markdown
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 elliottt and fitzgen 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
@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