Skip to content

Commit

Permalink
Suppress GS cookie checks in method epilogs (#40637)
Browse files Browse the repository at this point in the history
The information about end of GS cookie scope recorded in GC info is not accurate and it cannot even be made accurate without redesign that is not worth it. Detect end of GS cookie scope by comparing it with current SP instead.

Fixes #13041
  • Loading branch information
jkotas committed Aug 11, 2020
1 parent 857b2db commit 7d152b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/coreclr/src/vm/eetwain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5626,11 +5626,14 @@ void * EECodeManager::GetGSCookieAddr(PREGDISPLAY pContext,
INT32 spOffsetGSCookie = gcInfoDecoder.GetGSCookieStackSlot();
if (spOffsetGSCookie != NO_GS_COOKIE)
{
if(relOffset >= gcInfoDecoder.GetGSCookieValidRangeStart()
&& relOffset < gcInfoDecoder.GetGSCookieValidRangeEnd())
if(relOffset >= gcInfoDecoder.GetGSCookieValidRangeStart())
{
SIZE_T baseStackSlot = GetCallerSp(pContext);
return (LPVOID)( spOffsetGSCookie + baseStackSlot );
TADDR ptr = GetCallerSp(pContext) + spOffsetGSCookie;

// Detect the end of GS cookie scope by comparing its address with SP
// gcInfoDecoder.GetGSCookieValidRangeEnd() is not accurate. It does not
// account for GS cookie going out of scope inside epilog or multiple epilogs.
return (LPVOID) ((ptr >= pContext->SP) ? ptr : NULL);
}
}
return NULL;
Expand Down

0 comments on commit 7d152b7

Please sign in to comment.