-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Use QueueUserAPC2 for EE suspension on CoreCLR win-arm64. #101891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a0b2d53
use APC2 on arm64
VSadov b029f3e
Made AreCetShadowStacksEnabled available on arm64, with trivial imple…
VSadov 30c7cf6
Enabled querying for GetReturnAddressHijackTarget on arm64
VSadov 7bb78c4
Apply suggestions from code review
VSadov 687c1f5
updated #endif
VSadov 6d41c75
not handling STATUS_RETURN_ADDRESS_HIJACK_ATTEMPT if not in coop mode.
VSadov 8691cb2
Assert that a hijack target is provided when CET is enabled
VSadov 6d2b1ed
Nit
jkotas 7be5dbe
AreCetShadowStacksEnabled -> AreShadowStacksEnabled
jkotas 18c74f9
Update src/coreclr/vm/threadsuspend.cpp
jkotas 46f9962
Update src/coreclr/vm/threads.cpp
jkotas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ CLREvent* ThreadSuspend::g_pGCSuspendEvent = NULL; | |
|
|
||
| ThreadSuspend::SUSPEND_REASON ThreadSuspend::m_suspendReason; | ||
|
|
||
| #if defined(TARGET_WINDOWS) && defined(TARGET_AMD64) | ||
| #if defined(TARGET_WINDOWS) | ||
| void* ThreadSuspend::g_returnAddressHijackTarget = NULL; | ||
| #endif | ||
|
|
||
|
|
@@ -4747,13 +4747,13 @@ void Thread::HijackThread(ReturnKind returnKind, ExecutionState *esb) | |
|
|
||
| VOID *pvHijackAddr = reinterpret_cast<VOID *>(OnHijackTripThread); | ||
|
|
||
| #if defined(TARGET_WINDOWS) && defined(TARGET_AMD64) | ||
| #if defined(TARGET_WINDOWS) | ||
| void* returnAddressHijackTarget = ThreadSuspend::GetReturnAddressHijackTarget(); | ||
| if (returnAddressHijackTarget != NULL) | ||
| { | ||
| pvHijackAddr = returnAddressHijackTarget; | ||
| } | ||
| #endif // TARGET_WINDOWS && TARGET_AMD64 | ||
| #endif // TARGET_WINDOWS | ||
|
|
||
| #ifdef TARGET_X86 | ||
| if (returnKind == RT_Float) | ||
|
|
@@ -6062,22 +6062,20 @@ void ThreadSuspend::Initialize() | |
| #ifdef FEATURE_HIJACK | ||
| #if defined(TARGET_UNIX) | ||
| ::PAL_SetActivationFunction(HandleSuspensionForInterruptedThread, CheckActivationSafePoint); | ||
| #elif defined(TARGET_WINDOWS) && defined(TARGET_AMD64) | ||
| // Only versions of Windows that have the special user mode APC have a correct implementation of the return address hijack handling | ||
| if (Thread::UseSpecialUserModeApc()) | ||
| #elif defined(TARGET_WINDOWS) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dtto |
||
| if (Thread::AreShadowStacksEnabled()) | ||
| { | ||
| HMODULE hModNtdll = WszLoadLibrary(W("ntdll.dll")); | ||
| if (hModNtdll != NULL) | ||
| { | ||
| typedef ULONG_PTR (NTAPI *PFN_RtlGetReturnAddressHijackTarget)(); | ||
| PFN_RtlGetReturnAddressHijackTarget pfnRtlGetReturnAddressHijackTarget = (PFN_RtlGetReturnAddressHijackTarget)GetProcAddress(hModNtdll, "RtlGetReturnAddressHijackTarget"); | ||
| if (pfnRtlGetReturnAddressHijackTarget != NULL) | ||
| { | ||
| g_returnAddressHijackTarget = (void*)pfnRtlGetReturnAddressHijackTarget(); | ||
| } | ||
| g_returnAddressHijackTarget = (void*)GetProcAddress(hModNtdll, "RtlGetReturnAddressHijackTarget"); | ||
| } | ||
| if (g_returnAddressHijackTarget == NULL) | ||
| { | ||
| _ASSERTE_ALL_BUILDS(!"RtlGetReturnAddressHijackTarget must provide a target when shadow stacks are enabled"); | ||
| } | ||
| } | ||
| #endif // TARGET_WINDOWS && TARGET_AMD64 | ||
| #endif // TARGET_WINDOWS | ||
| #endif // FEATURE_HIJACK | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Update comment on #endif