Skip to content

Commit 595dcd5

Browse files
authored
Fix off-by-one in aot_alloc_tiny_frame overflow check (#4845)
* Fix off-by-one in aot_alloc_tiny_frame overflow check The boundary check in aot_alloc_tiny_frame only verifies that new_frame itself doesn't exceed top_boundary, but doesn't account for the sizeof(AOTTinyFrame) bytes that are about to be written. When new_frame equals top_boundary exactly, the check passes but the subsequent write to new_frame->func_index goes past the boundary. This matches the correct pattern used in aot_alloc_frame (line 4086) which includes the frame size.
1 parent 01f4ff4 commit 595dcd5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/iwasm/aot/aot_runtime.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4176,7 +4176,8 @@ aot_alloc_tiny_frame(WASMExecEnv *exec_env, uint32 func_index)
41764176
{
41774177
AOTTinyFrame *new_frame = (AOTTinyFrame *)exec_env->wasm_stack.top;
41784178

4179-
if ((uint8 *)new_frame > exec_env->wasm_stack.top_boundary) {
4179+
if ((uint8 *)new_frame + sizeof(AOTTinyFrame)
4180+
> exec_env->wasm_stack.top_boundary) {
41804181
aot_set_exception((WASMModuleInstance *)exec_env->module_inst,
41814182
"wasm operand stack overflow");
41824183
return false;

0 commit comments

Comments
 (0)