Skip to content

Commit 64dbaa2

Browse files
committed
fix: stack frame corruption
This commit fixes the issue where passing more than 6 args would lead to being duplication, leading to stack frame corruption.
1 parent 1767ae2 commit 64dbaa2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

loader/src/ptracer/utils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ uintptr_t remote_call(int pid, struct user_regs_struct *regs, uintptr_t func_add
410410
long remain = (args_size - 6L) * sizeof(long);
411411
align_stack(regs, remain);
412412

413-
if (!write_proc(pid, (uintptr_t) regs->REG_SP, args, remain)) LOGE("failed to push arguments");
413+
if (!write_proc(pid, (uintptr_t) regs->REG_SP, &args[6], remain)) LOGE("failed to push arguments");
414414
}
415415

416416
regs->REG_SP -= sizeof(long);
@@ -440,7 +440,7 @@ uintptr_t remote_call(int pid, struct user_regs_struct *regs, uintptr_t func_add
440440
long remain = (args_size - 8) * sizeof(long);
441441
align_stack(regs, remain);
442442

443-
write_proc(pid, (uintptr_t)regs->REG_SP, args, remain);
443+
write_proc(pid, (uintptr_t)regs->REG_SP, &args[8], remain);
444444
}
445445

446446
regs->regs[30] = return_addr;
@@ -454,7 +454,7 @@ uintptr_t remote_call(int pid, struct user_regs_struct *regs, uintptr_t func_add
454454
long remain = (args_size - 4) * sizeof(long);
455455
align_stack(regs, remain);
456456

457-
write_proc(pid, (uintptr_t)regs->REG_SP, args, remain);
457+
write_proc(pid, (uintptr_t)regs->REG_SP, &args[4], remain);
458458
}
459459

460460
regs->uregs[14] = return_addr;

0 commit comments

Comments
 (0)