Skip to content

Conversation

Septa2112
Copy link
Contributor

In Fast-Interpreter mode, wasm_loader_pop_frame_offset does not validate dynamic_offset before performing calculations. This can lead to an potential unsigned integer underflow in certain cases, for example when cell_num_to_pop exceeds dynamic_offset:

ctx->dynamic_offset -= cell_num_to_pop;

This patch adds a validation step for dynamic_offset to prevent such cases and improve code robustness.

@lum1n0us lum1n0us added the bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs. label Aug 15, 2025
@kylo5aby
Copy link
Contributor

kylo5aby commented Sep 3, 2025

should also update mini loader part

@lum1n0us
Copy link
Collaborator

This issue concerns an unsigned integer underflow, such as (3-4), which is captured by the sanitizer. If there is no sanitizer, a subsequent checker will detect it and report an exception. Therefore, the malformed Wasm won't cause any problems during the instantiation and execution phases.

And according to Clang's Undefined Behavior Sanitizer documentation, including unsigned integer underflow in sanitizer options is more like asking the developer if this is intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants