Browse Source
* winch: Solidify bounds check for dynamic heaps This commit fixes and edge case for bounds checks for dynamic heaps. https://github.com/bytecodealliance/wasmtime/pull/8157/files erroneously tied the bounds check operation (more concretely the overflow check) to the size derived from from the heap type. Even though offsets and access sizes are validated ahead-of-time and bound to the heap type, in the case of overflow checking, we must ensure that the operation size is tied to the target's pointer size to avoid clamping the access size and offset addition, which would result in missing an out-of-bounds memory access. This commit also adds a disassembly test to avoid introducing regressions in the future. Additionally, this commit adds more comments around why `pointer_size` is used for certain bounds checking operations. * Update disassembly testpull/9158/head
Saúl Cabrera
3 months ago
committed by
GitHub
3 changed files with 84 additions and 3 deletions
@ -0,0 +1,48 @@ |
|||
;;! target = "x86_64" |
|||
;;! test = "winch" |
|||
;;! flags = " -O static-memory-maximum-size=0" |
|||
(module |
|||
(memory 1) |
|||
(func (export "foo") (param $i i32) |
|||
i32.const 0 |
|||
(local.get $i) |
|||
i32.store8 offset=4294967295 |
|||
) |
|||
) |
|||
|
|||
;; wasm[0]::function[0]: |
|||
;; pushq %rbp |
|||
;; movq %rsp, %rbp |
|||
;; movq 8(%rdi), %r11 |
|||
;; movq (%r11), %r11 |
|||
;; addq $0x20, %r11 |
|||
;; cmpq %rsp, %r11 |
|||
;; ja 0x85 |
|||
;; 1b: movq %rdi, %r14 |
|||
;; subq $0x20, %rsp |
|||
;; movq %rdi, 0x18(%rsp) |
|||
;; movq %rsi, 0x10(%rsp) |
|||
;; movl %edx, 0xc(%rsp) |
|||
;; movl 0xc(%rsp), %eax |
|||
;; movl $0, %ecx |
|||
;; movq 0x68(%r14), %rdx |
|||
;; movl %ecx, %ebx |
|||
;; movabsq $0x100000000, %r11 |
|||
;; addq %r11, %rbx |
|||
;; jb 0x87 |
|||
;; 52: cmpq %rdx, %rbx |
|||
;; ja 0x89 |
|||
;; 5b: movq 0x60(%r14), %rsi |
|||
;; addq %rcx, %rsi |
|||
;; movabsq $0xffffffff, %r11 |
|||
;; addq %r11, %rsi |
|||
;; movq $0, %rdi |
|||
;; cmpq %rdx, %rbx |
|||
;; cmovaq %rdi, %rsi |
|||
;; movb %al, (%rsi) |
|||
;; addq $0x20, %rsp |
|||
;; popq %rbp |
|||
;; retq |
|||
;; 85: ud2 |
|||
;; 87: ud2 |
|||
;; 89: ud2 |
@ -0,0 +1,10 @@ |
|||
(module |
|||
(memory 1) |
|||
(func (export "foo") (param $i i32) |
|||
i32.const 0 |
|||
(local.get $i) |
|||
i32.store8 offset=4294967295 |
|||
) |
|||
) |
|||
|
|||
(assert_trap (invoke "foo" (i32.const 0)) "out of bounds") |
Loading…
Reference in new issue