Skip to content

Commit c2aaf80

Browse files
committed
runtime: Fix unaligned access in permissive mode
Seems like crt functions don't follow the SysV ABI as strictly since stack frames below `main` sometimes lead to dereferencing unaligned frame pointers.
1 parent 3ae414b commit c2aaf80

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

runtime/libia2/include/permissive_mode.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,12 @@ void permissive_mode_handler(int sig, siginfo_t *info, void *ctxt) {
212212
if (fp < PAGE_SIZE) {
213213
break;
214214
}
215-
uint64_t ra = *(uint64_t *)(fp + 8);
215+
uint64_t ra;
216+
memcpy(&ra, fp + 8, sizeof(uint64_t));
216217
err.ret_addrs[i] = ra;
217-
fp = *(uint64_t *)fp;
218+
uint64_t next_fp;
219+
memcpy(&next_fp, fp, sizeof(uint64_t));
220+
fp = next_fp;
218221
}
219222
push_queue(q, err);
220223
release_queue(q);

0 commit comments

Comments
 (0)