Fixed some potential integer overflows in coreclr#124047
Merged
jkotas merged 15 commits intodotnet:mainfrom Feb 17, 2026
Merged
Fixed some potential integer overflows in coreclr#124047jkotas merged 15 commits intodotnet:mainfrom
jkotas merged 15 commits intodotnet:mainfrom
Conversation
In the MCList::processArgAsMCL function, an input string consisting of digits and the characters ',' and '-' is parsed into a set of numbers and/or ranges of numbers. If the string contains a number greater than UINT_MAX, the scratch variable will overflow. The input string often comes from command-line arguments, so protection is necessary.
The result of the multiplication will be of type uint32_t, since the highest operand type is uint32_t, so overflow will occur if num_heaps > 255. To promote the result to size_t, you must explicitly convert at least one of the operands to size_t.
huoyaoyuan
reviewed
Feb 5, 2026
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/gc |
Contributor
Author
|
Hi @agocke @dotnet/gc. Could you please take a look when you have a moment and let me know if this is ready to merge or if you’d like changes? Thanks! |
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.
Fixed some potential integer overflows in gc.cpp and mclist.cpp. The errors were discovered using the Svace static analyzer. I didn't observe any in practice.
In
gc_heap::joined_youngest_desiredthe result of the multiplication will be of typeuint32_t, since the highest operand type isuint32_t, so overflow will occur ifnum_heaps > 255. To promote the result tosize_t, you must explicitly convert at least one of the operands tosize_t.In the
MCList::processArgAsMCL, an input string consisting of digits and the characters ',' and '-' is parsed into a set of numbers and/or ranges of numbers. If the string contains a number greater thanUINT_MAX, thescratchwill overflow. Theinputstring often comes from command-line arguments, so protection is necessary.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reporter: Pavel Tikhomirov (Tihomirov-P@gaz-is.ru).
Organization: Gazinformservice (resp@gaz-is.ru).