[release/10.0] Fix TOCTOU race in AppDomain::LoadAssembly fast-path#125424
Merged
JulieLeeMSFT merged 1 commit intorelease/10.0from Mar 11, 2026
Merged
[release/10.0] Fix TOCTOU race in AppDomain::LoadAssembly fast-path#125424JulieLeeMSFT merged 1 commit intorelease/10.0from
JulieLeeMSFT merged 1 commit intorelease/10.0from
Conversation
PR #120515 deferred Assembly creation (lazy init), making FileLoadLock::m_pAssembly mutable. The fast-path in LoadAssembly cached pAssembly before checking GetLoadLevel(), so a thread could read nullptr, get preempted while another thread completed the load, then pass the level check and dereference the stale nullptr. Re-read pAssembly from the FileLoadLock inside the fast-path block after the level check passes, ensuring we use the pointer that corresponds to the observed load level. Co-authored-by: Copilot <[email protected]>
Contributor
|
Tagging subscribers to this area: @agocke |
elinor-fung
approved these changes
Mar 11, 2026
Member
|
/ba-g The test failure is a known issue. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of #125408 to release/10.0
/cc @AaronRobinsonMSFT
Customer Impact
The reproduction rate in a real application environment is extremely low (< 1/100,000) as it requires simultaneous EOF on stdout/stderr, an unloaded target assembly, and exact OS thread preemption. This is a reliability issue tht impacted a high value enterprise customer and can impact other users.
Regression
Yes in PR #120515.
Testing
The change here is an obvious TOCTOU issue. The source was updated in a clearer way to avoid creating locals that are populated long before use.
Risk
Low. The source change is narrowing the use of a local behind a lock in a manner that is more local to use. This reflects better engineering practices and can easily be audited for correctness.