Skip to content

Conversation

@tpa95
Copy link
Contributor

@tpa95 tpa95 commented Jan 14, 2026

If under certain conditions op can take the value OP_LAST, an overflow will occur because the opidx array contains OP_LAST - OP_LOAD elements.

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reporter: Pavel Tikhomirov ([email protected]).
Organization: Gazinformservice ([email protected]).

If under certain conditions op can take the value OP_LAST, an overflow will occur because the opidx array contains OP_LAST - OP_LOAD elements.
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 14, 2026
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 14, 2026
Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot - looks good to me.

@vitek-karas vitek-karas requested a review from BrzVlad January 14, 2026 08:24
@BrzVlad
Copy link
Member

BrzVlad commented Jan 14, 2026

@tpa95 Did this ever happen in practice somewhere ? It would be asserting now, so that would need to be fixed as well.

@tpa95
Copy link
Contributor Author

tpa95 commented Jan 14, 2026

@BrzVlad No, I didn’t observe it in practice; it was reported by static analysis (Svace) as a buffer overflow issue. OP_LAST is a sentinel and not a valid opcode to be passed to mono_inst_name(). Now, if op == OP_LAST we can index opidx out of bounds (op - OP_LOAD), which is UB. Changing the condition to op < OP_LAST avoids the buffer overflow.

@jkotas jkotas added area-Codegen-JIT-mono and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 14, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @steveisok, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@BrzVlad BrzVlad merged commit ccd2679 into dotnet:main Jan 14, 2026
74 checks passed
@tpa95 tpa95 deleted the fix/mono-overflow-fix branch January 14, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Codegen-JIT-mono community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants