Skip to content

Instantly share code, notes, and snippets.

@tommie
Created August 9, 2024 10:55
Show Gist options
  • Save tommie/04d77358c4006df94106f8e63a71cfec to your computer and use it in GitHub Desktop.
Save tommie/04d77358c4006df94106f8e63a71cfec to your computer and use it in GitHub Desktop.
wasm3/wasm3#477 repro 2
(module
(func $func132 (param i32 i32 i32 i32))
(func $main
i32.const 0
i32.const 0
i32.const 0
i32.const 0
call $func132)
(export "main" (func $main))
)
Stack size 20
runtime | new stack: 0x504000000010
runtime | resized old: 0x503000000160; mem: 0x503000000160; length: 0; pages: 0
compile | compiling: [1] main () -> ; wasm-size: 13
runtime | new page: 0x52d000000418; seq: 1; bytes: 32768; lines: 4093
emit | acquire page: 1
compile | reserved constant slots: 4
compile | start stack index: 0
emit | 0x52d000000418: Entry
emit | not found: 0x55c91a95ec39
compile | 0 | 0x41 .. i32.const
stack |
stack |
stack | >|0
stack | >|ic0
stack |
compile | | .......... (const i32 = 0)
compile | 1 | 0x41 .. i32.const
stack |
stack |
stack | >|0 |1
stack | >|ic0 |ic0
stack |
compile | | .......... (const i32 = 0)
compile | 2 | 0x41 .. i32.const
stack |
stack |
stack | >|0 |1 |2
stack | >|ic0 |ic0 |ic0
stack |
compile | | .......... (const i32 = 0)
compile | 3 | 0x41 .. i32.const
stack |
stack |
stack | >|0 |1 |2 |3
stack | >|ic0 |ic0 |ic0 |ic0
stack |
compile | | .......... (const i32 = 0)
compile | 4 | 0x10 .. call
compile | | .......... (func= [0] '$func0'; args= 4)
emit | 0x52d000000448: CopySlot_32
emit | 0x52d000000460: CopySlot_32
emit | 0x52d000000478: CopySlot_32
emit | 0x52d000000490: CopySlot_32
emit | 0x52d0000004a8: Compile
emit | not found: 0x55c91a95ec39
compile | 5 | 0x0b end
stack |
stack |
stack |
stack |
stack |
emit | 0x52d0000004e0: return
compile | unique constant slots: 1; unused slots: 3
emit | release page: 1 to queue: 'open'
runtime | runtime: 0x526000000100; open-pages: 1; full-pages: 0; active: 0; total: 1
0 main r0: 0x0000000000000000 i:0 u:0
fp0: 0.000000
0x504000000010 0: 0x0 i:0
0x504000000014 1: 0x0 i:0
0x504000000018 2: 0x0 i:0
0x50400000001c 3: 0x0 i:0
---------------------------------------------------------------------------------------------------------
=================================================================
==185534==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x504000000038 at pc 0x55c91a95e6bf bp 0x7ffdb270fa10 sp 0x7ffdb270fa00
WRITE of size 4 at 0x504000000038 thread T0
#0 0x55c91a95e6be in op_CopySlot_32 /home/tommie/code/uniface/firmware/lib/wasm3/source/m3_exec.h:980
#1 0x55c91a95ef96 in op_DumpStack /home/tommie/code/uniface/firmware/lib/wasm3/source/m3_exec.h:1050
#2 0x55c91a95d285 in op_Entry /home/tommie/code/uniface/firmware/lib/wasm3/source/m3_exec.h:835
#3 0x55c91a98304b in RunCode /home/tommie/code/uniface/firmware/lib/wasm3/source/m3_exec_defs.h:71
#4 0x55c91a989859 in m3_CallArgv /home/tommie/code/uniface/firmware/lib/wasm3/source/m3_env.c:1013
#5 0x55c91a92a756 in repl_call /home/tommie/code/uniface/firmware/lib/wasm3/platforms/app/main.c:298
#6 0x55c91a92d4bc in main /home/tommie/code/uniface/firmware/lib/wasm3/platforms/app/main.c:639
#7 0x7d36540691c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#8 0x7d365406928a in __libc_start_main_impl ../csu/libc-start.c:360
#9 0x55c91a9292b4 in _start (/home/tommie/code/uniface/firmware/lib/wasm3/build/wasm3+0x3e2b4) (BuildId: b73c615f96e5598edd3a9982da40415e4de22e9d)
0x504000000038 is located 4 bytes after 36-byte region [0x504000000010,0x504000000034)
allocated by thread T0 here:
#0 0x7d36544354d0 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x55c91a9817e3 in m3_Malloc_Impl /home/tommie/code/uniface/firmware/lib/wasm3/source/m3_core.c:129
#2 0x55c91a983a9b in m3_NewRuntime /home/tommie/code/uniface/firmware/lib/wasm3/source/m3_env.c:184
#3 0x55c91a92c2f4 in repl_init /home/tommie/code/uniface/firmware/lib/wasm3/platforms/app/main.c:474
#4 0x55c91a92d33f in main /home/tommie/code/uniface/firmware/lib/wasm3/platforms/app/main.c:623
#5 0x7d36540691c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#6 0x7d365406928a in __libc_start_main_impl ../csu/libc-start.c:360
#7 0x55c91a9292b4 in _start (/home/tommie/code/uniface/firmware/lib/wasm3/build/wasm3+0x3e2b4) (BuildId: b73c615f96e5598edd3a9982da40415e4de22e9d)
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/tommie/code/uniface/firmware/lib/wasm3/source/m3_exec.h:980 in op_CopySlot_32
Shadow bytes around the buggy address:
0x503ffffffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x503ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x503ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x503fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x503fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x504000000000: fa fa 00 00 00 00 04[fa]fa fa 00 00 00 00 00 00
0x504000000080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x504000000100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x504000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x504000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x504000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==185534==ABORTING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment