Skip to content

Commit 9989b1c

Browse files
authored
[fuzzing] Use software bound-check during fuzzing (#4003)
* Update CMakeLists.txt of fuzzing - enable software bound-check - enable wasi - disable libc builtin and multiple modules * Fix off-by-one error in result offset calculation for function calls
1 parent 1807eec commit 9989b1c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
16701670
{
16711671
uint32 ret_idx;
16721672
WASMFuncType *func_type;
1673-
uint32 off, ret_offset;
1673+
int32 off;
1674+
uint32 ret_offset;
16741675
uint8 *ret_types;
16751676
if (cur_func->is_import_func)
16761677
func_type = cur_func->u.func_import->func_type;
@@ -1682,9 +1683,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
16821683
ret_offset = prev_frame->ret_offset;
16831684

16841685
for (ret_idx = 0,
1685-
off = sizeof(int16) * (func_type->result_count - 1);
1686+
off = (int32)sizeof(int16) * (func_type->result_count - 1);
16861687
ret_idx < func_type->result_count;
1687-
ret_idx++, off -= sizeof(int16)) {
1688+
ret_idx++, off -= (int32)sizeof(int16)) {
16881689
if (ret_types[ret_idx] == VALUE_TYPE_I64
16891690
|| ret_types[ret_idx] == VALUE_TYPE_F64) {
16901691
PUT_I64_TO_ADDR(prev_frame->lp + ret_offset,

tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (NOT DEFINED WAMR_BUILD_JIT)
6666
endif ()
6767

6868
if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
69-
# Enable libc builtin support by default
69+
# Disable libc builtin support by default
7070
set (WAMR_BUILD_LIBC_BUILTIN 0)
7171
endif ()
7272

@@ -81,7 +81,7 @@ if (NOT DEFINED WAMR_BUILD_FAST_INTERP)
8181
endif ()
8282

8383
if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
84-
# Enable multiple modules
84+
# Disable multiple modules
8585
set (WAMR_BUILD_MULTI_MODULE 0)
8686
endif ()
8787

@@ -116,6 +116,10 @@ if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
116116
set (WAMR_BUILD_SIMD 0)
117117
endif ()
118118

119+
# sanitizer may use kHandleSignalExclusive to handle SIGSEGV
120+
# like `UBSAN_OPTIONS=handle_segv=2:...`
121+
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
122+
119123
set (REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
120124
message([ceith]:REPO_ROOT_DIR, ${REPO_ROOT_DIR})
121125

0 commit comments

Comments
 (0)