Skip to content

Commit

Permalink
flamenco, vm: fix overlapping check and perform overlap check on host…
Browse files Browse the repository at this point in the history
… address
  • Loading branch information
topointon-jump committed Feb 24, 2025
1 parent c1459ec commit e407cf4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ dump/test-vectors/syscall/fixtures/try_find_program_address/bc322c44298746ad781c
dump/test-vectors/syscall/fixtures/try_find_program_address/d12060e6dedc6065c4b9e35e111dc85b38eb5d61_2015586.fix
dump/test-vectors/syscall/fixtures/try_find_program_address/d3e7db89c3cce9108a146398962ce32cd373cd9d_286202.fix
dump/test-vectors/syscall/fixtures/try_find_program_address/fee80a4e7a81c0388760a08e54bfec4fca9794d8_6452.fix
dump/test-vectors/syscall/fixtures/try_find_program_address/4d25554ba985dea7919428fd2e6fffc10b8c2568_362259.fix
4 changes: 2 additions & 2 deletions src/flamenco/vm/syscall/fd_vm_syscall_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ FD_VM_MEM_HADDR_ST_( fd_vm_t const *vm, ulong vaddr, ulong align, ulong sz, int

/* FIXME: use overlap logic from runtime? */
#define FD_VM_MEM_CHECK_NON_OVERLAPPING( vm, vaddr0, sz0, vaddr1, sz1 ) do { \
if( FD_UNLIKELY( ((vaddr0> vaddr1) && ((vaddr0-vaddr1)<sz1)) || \
((vaddr1>=vaddr0) && ((vaddr1-vaddr0)<sz0)) ) ) { \
if( FD_UNLIKELY(( ((vaddr0 > vaddr1) && (fd_ulong_sat_sub(vaddr0, vaddr1) < sz1)) ) || \
( ((vaddr1 >= vaddr0) && (fd_ulong_sat_sub(vaddr1, vaddr0) < sz0)) ) )) { \
FD_VM_ERR_FOR_LOG_SYSCALL( vm, FD_VM_SYSCALL_ERR_COPY_OVERLAPPING ); \
return FD_VM_SYSCALL_ERR_COPY_OVERLAPPING; \
} \
Expand Down
2 changes: 1 addition & 1 deletion src/flamenco/vm/syscall/fd_vm_syscall_pda.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ fd_vm_syscall_sol_try_find_program_address( void * _vm,
}

/* Do the overlap check, which is only included for this syscall */
FD_VM_MEM_CHECK_NON_OVERLAPPING( vm, out_vaddr, 32UL, out_bump_seed_vaddr, 1UL );
FD_VM_MEM_CHECK_NON_OVERLAPPING( vm, (ulong)out_haddr, 32UL, (ulong)out_bump_seed_haddr, 1UL );

memcpy( out_haddr, derived, sizeof(fd_pubkey_t) );
*out_bump_seed_haddr = (uchar)*bump_seed;
Expand Down

0 comments on commit e407cf4

Please sign in to comment.