Skip to content

Commit

Permalink
runtime: Fix unaligned access in permissive mode
Browse files Browse the repository at this point in the history
Seems like crt functions don't follow the SysV ABI as strictly since stack
frames below `main` sometimes lead to dereferencing unaligned frame pointers.
  • Loading branch information
ayrtonm committed Oct 7, 2024
1 parent 14eea20 commit 5653188
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions runtime/libia2/include/permissive_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,12 @@ void permissive_mode_handler(int sig, siginfo_t *info, void *ctxt) {
if (fp < PAGE_SIZE) {
break;
}
uint64_t ra = *(uint64_t *)(fp + 8);
uint64_t ra;
memcpy(&ra, fp + 8, sizeof(uint64_t));
err.ret_addrs[i] = ra;
fp = *(uint64_t *)fp;
uint64_t next_fp;
memcpy(&next_fp, fp, sizeof(uint64_t));
fp = next_fp;
}
push_queue(q, err);
release_queue(q);
Expand Down

0 comments on commit 5653188

Please sign in to comment.