still protect against infinite unwinds, but require that both rsp/rip remain unchanged, rather than just rip

This commit is contained in:
Ryan Fleury
2025-05-14 13:55:16 -07:00
parent 99a8108b2a
commit 1e53ac29ef
+4 -1
View File
@@ -3099,6 +3099,7 @@ ctrl_unwind_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_Handle threa
{
// rjf: regs -> rip*module
U64 rip = regs_rip_from_arch_block(arch, regs_block);
U64 rsp = regs_rsp_from_arch_block(arch, regs_block);
CTRL_Entity *module = &ctrl_entity_nil;
for(CTRL_Entity *m = process_entity->first; m != &ctrl_entity_nil; m = m->next)
{
@@ -3128,7 +3129,9 @@ ctrl_unwind_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_Handle threa
unwind.flags |= step.flags;
if(step.flags & CTRL_UnwindFlag_Error ||
regs_rsp_from_arch_block(arch, regs_block) == 0 ||
regs_rip_from_arch_block(arch, regs_block) == 0)
regs_rip_from_arch_block(arch, regs_block) == 0 ||
(regs_rsp_from_arch_block(arch, regs_block) == rsp &&
regs_rip_from_arch_block(arch, regs_block) == rip))
{
break;
}