Avoid out-of-bounds section_starts_ read on invalid reloc index#2777
Merged
Conversation
An out-of-range reloc.* section index leaves reloc_section_ as BinarySection::Invalid; the details-mode OnRelocCount ignored the base error and let OnReloc index section_starts_ with the sentinel. Propagate the result so the section is rejected.
sbc100
approved these changes
Jun 24, 2026
sbc100
approved these changes
Jun 24, 2026
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.
UBSan,
wasm-objdump -xon a crafted module:The input is a
reloc.*custom section whose section index points past the last section. The baseOnRelocCountspots that, setsreloc_section_toBinarySection::Invalid(~0) and returnsErrorto abort the section. The details-mode override dropped that result and returnedOk, soReadRelocSectioncarried on intoOnReloc, whereGetSectionStart(reloc_section_)readssection_starts_[(size_t)-1].Resultis not[[nodiscard]], so the dropped error built clean. Propagating it withCHECK_RESULTrejects the bad index the same way the other reader modes already do.bad-relocs.txtused a zero relocation count, so it never reachedOnReloc; gave it one entry so it covers the read.