Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit fa682a7

Browse files
authored
Fix return address hijack in probing loop (#28119)
When return address hijacking occurs when the target thread is running in the stack probing loop in a method with large frame, the unwinder cannot unwind to the caller frame correctly. That results in a wrong stack slot being patched by the modified return address, leading to corruption of locals of the method being executed. This change fixes the problem by not attempting to hijack a method that's running in prolog.
1 parent 3c95aa2 commit fa682a7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/vm/threadsuspend.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6727,6 +6727,17 @@ void HandleGCSuspensionForInterruptedThread(CONTEXT *interruptedContext)
67276727

67286728
BOOL unused;
67296729

6730+
#if defined(FEATURE_PAL) && (defined(_TARGET_AMD64_) || defined(_TARGET_X86_))
6731+
// Stack probing loop that JIT generates in prolog on x64 / x86 Unix for methods with
6732+
// large frame is not unwindable, so it is not possible to get the return address location
6733+
// for hijacking.
6734+
// This is a hotfix for release/3.1 only.
6735+
if (IsIPInProlog(&codeInfo) && codeInfo.GetFixedStackSize() >= 0x3000)
6736+
{
6737+
return;
6738+
}
6739+
#endif // _TARGET_UNIX_ && (TARGET_AMD64 || TARGET_X86)
6740+
67306741
if (IsIPInEpilog(interruptedContext, &codeInfo, &unused))
67316742
return;
67326743

0 commit comments

Comments
 (0)