ctrl thread stepping machine: read initial stack-pointer-check-value *before* single-stepping stuck threads, otherwise we can obtain an incorrect stack check value if the single-step causes a call.

This commit is contained in:
Ryan Fleury
2024-03-22 17:27:54 -07:00
parent c26274ac70
commit 83ecb4b86a
+9 -1
View File
@@ -2861,6 +2861,15 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
}
}
//////////////////////////////
//- rjf: read initial stack-pointer-check value
//
// This MUST happen before any threads move, including single-stepping stuck
// threads, because otherwise, their stack pointer may change, if single-stepping
// causes e.g. entrance into a function via a call instruction.
//
U64 sp_check_value = dmn_rsp_from_thread(target_thread);
//////////////////////////////
//- rjf: single step "stuck threads"
//
@@ -3011,7 +3020,6 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
//
if(stop_event == 0)
{
U64 sp_check_value = dmn_rsp_from_thread(target_thread);
B32 spoof_mode = 0;
CTRL_Spoof spoof = {0};
for(;;)