Skip to content

Commit

Permalink
aot_reloc_x86_64: Fix pointer overflows (#809)
Browse files Browse the repository at this point in the history
Fix pointer overflow of `(uint8 *)symbol_addr + reloc_addend` detected by UBSan:
```
core/iwasm/aot/arch/aot_reloc_x86_64.c:232:43: runtime error: addition of unsigned offset to 0x000041209004 overflowed to 0x000041209000
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior core/iwasm/aot/arch/aot_reloc_x86_64.c:232:43
```
  • Loading branch information
yamt authored Nov 8, 2021
1 parent 487072a commit 2613a68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/iwasm/aot/arch/aot_reloc_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,13 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
- get_plt_table_size()
+ get_plt_item_size() * symbol_index;
target_addr = (intptr_t) /* L + A - P */
(plt + reloc_addend - (target_section_addr + reloc_offset));
((uintptr_t)plt + reloc_addend
- (uintptr_t)(target_section_addr + reloc_offset));
}
else {
target_addr = (intptr_t) /* L + A - P */
((uint8 *)symbol_addr + reloc_addend
- (target_section_addr + reloc_offset));
((uintptr_t)symbol_addr + reloc_addend
- (uintptr_t)(target_section_addr + reloc_offset));
}

#if defined(BH_PLATFORM_WINDOWS)
Expand Down

0 comments on commit 2613a68

Please sign in to comment.