fix oob write in memberRemapper for nested buffer_reference blocks#4326
Open
saddamr3e wants to merge 1 commit into
Open
fix oob write in memberRemapper for nested buffer_reference blocks#4326saddamr3e wants to merge 1 commit into
saddamr3e wants to merge 1 commit into
Conversation
memberRemapper was keyed through glslangTypeToIdMap, whose operator[] hands back id 0 for structs never registered from a visited symbol, so distinct buffer_reference blocks shared one remapper vector. Converting a nested block resized that shared vector smaller and the outer block's next member write went out of bounds. Key it by the member-list pointer so each block gets its own slot.
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.
ASAN, compiling a push-constant
buffer_referenceblock whose first member is a struct wrapping anotherbuffer_reference(repro from #3977):memberRemapperwas keyed throughglslangTypeToIdMap, whoseoperator[]returns id 0 for any struct member list never registered from a visited symbol.buffer_referenceblocks reached only while building types are never registered, so distinct blocks all land onmemberRemapper[0]. Converting the inner one-member block resizes that shared vector down to 1, then the outer two-member block's next member write runs past the end. In release builds the write just corrupts the heap silently, which is why it only shows up under a sanitizer or MSVC debug iterators.glslangTypeToIdMapexisted only to produce this key, so keyingmemberRemapperby the member-list pointer directly removes the collision and the map. Addedspv.bufferReferenceNestedStruct.compfor the case; it trips the sanitizer before the fix and passes after.Fixes #3977.