-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Load Standalone GC correctly in component scenarios. #120012
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
Load Standalone GC correctly in component scenarios. #120012
Conversation
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.
Pull Request Overview
This PR fixes a security vulnerability in standalone GC loading for .NET component scenarios (like C++/CLI). When APP_CONTEXT_BASE_DIRECTORY is empty in component scenarios, the GC library could be loaded from anywhere in the default search path, creating a potential security risk.
Key changes:
- Add validation to check if
APP_CONTEXT_BASE_DIRECTORYis an empty string - Skip the app base directory path when it's empty, forcing fallback to the coreclr binary directory
- Add explanatory comments about the component scenario behavior
|
Tagging subscribers to this area: @dotnet/gc |
|
/cc @dotnet/gc |
|
Thanks for the fix, @AaronRobinsonMSFT . Could it be backported to .NET 10 as it impacts the upgrade to this LTS release? |
Would it be possible to use the more precise mechaism I mentioned at #119418 (comment)? Use |
|
/backport to release/10.0 |
|
/backport to release/9.0-staging |
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/18112369317 |
|
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/18112372375 |
|
Thanks for the backporting, @AaronRobinsonMSFT . The reason that we have to use |
|
Is there a specific reason for using clrgc.dll? Are you still using segments based GC? |
|
We are using clrgc.dll because the default GC implementation will reserve more than 200 GB memory for the managed heap. This makes our capacity tests reporting false regressions. With clrgc.dll, the results restore to the previous level. We are actually not aware other differences between the default GC and clrgc.dll. |
|
If its a memory reservation issue you can use the |
|
Thanks @mangod9 . I tried the |
|
It's a static setting and the reservation size cannot be expanded. You should set it to something reasonable like the amount of physical memory on your VM/container. In |
|
Thank you for the advice @mangod9. If the value is too big, then the capacity tests will still report false regressions. We will try to tune the value so that it will be enough and also be acceptable for the capacity tests. |
In .NET component scenarios (for example, C++/CLI), the
APP_CONTEXT_BASE_DIRECTORYproperty is set to an empty string. When the standalone GC scenario is exercised usingSystem.GC.NameorDOTNET_GCName, the empty directory is used as the path and the name appended to nothing. The result is for the load to use the default search path and could load the GC from anywhere. The solution is to useSystem.GC.PathorDOTNET_GCPathto get the desired behavior and we "fix" the component issue by going down the fallback path and use the same directory as thecoreclrbinary.Fixes #119418