Repository navigation
GH-44827: [C++] Skip null slots when transposing dictionary indices - #54686
Closed
Nayana-Naik73 wants to merge 1 commit into
Closed
Nayana-Naik73 wants to merge 1 commit into
Nayana-Naik73 wants to merge 1 commit into
Conversation
|
|
|
Thanks for opening a pull request! This pull request has been automatically closed because you currently have 4 open pull requests, which is more than the limit of 3. Due to the increase in pull requests opened by AI bots, and in order to keep the review queue manageable, Apache Arrow limits contributors without repository access to at most 3 concurrently open pull requests. This helps make sure each pull request gets the attention it needs and that work in progress does not go stale. Once one of your other open pull requests has been merged or closed, you are welcome to reopen this one. See also: |
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.
Rationale for this change
TransposeDictIndices(behindDictionaryArray::Transpose,DictionaryArray::Compact,DictionaryUnifier::UnifyChunkedArray/UnifyTable, and the hash kernels when chunks have different dictionaries) passes every index toTransposeInts, null slots included, andTransposeIntsreadstranspose_map[index]. Index values under null slots are unspecified, andValidateFull()deliberately does not bounds-check them. So a dictionary array with a large or negative index under a null slot validates fine and then reads far outsidetranspose_map. This is the crash described in GH-44827.You can hit it from untrusted input: write an IPC stream with two batches whose
dictionary<int32, utf8>column has different dictionaries and1 << 30stored under a null index. Read it back withRecordBatchStreamReader. Both batches passValidateFull(), and thenDictionaryUnifier::UnifyChunkedArraydies under ASan with a BUS/READ fault inTransposeInts(int_util.cc:427, called fromarray_dict.cc:206).ConcatenateDictionaryIndicesalready skips null runs for this reason. The transpose path never got the same treatment.What changes are included in this PR?
TransposeDictIndiceszeroes the output indices when the input may have nulls and transposes only the valid runs withVisitSetBitRuns. Valid indices are transposed exactly as before.Are these changes tested?
Yes.
TestDictionary.TransposeNullsWithOutOfBoundsIndexbuilds a dictionary array that passesValidateFull()and has out-of-range values (1 << 30and-(1 << 30)) under its null slots. It checksTranspose, a slicedTranspose, andCompact. Without the fix it crashes inTransposeInts; with the fix it passes.arrow-array-testandarrow-compute-vector-testpass in an ASan debug build.Are there any user-facing changes?
No, other than the crash being fixed. Null slots in a transposed index buffer now hold 0 instead of an arbitrary value.
This PR contains a "Critical Fix". It fixes an out-of-bounds read reachable from arrays that pass
ValidateFull(), for example dictionary-encoded columns read from an untrusted IPC stream and then unified or compacted.Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by:
This was prepared with AI assistance (the patch, the regression test and this description), and I reviewed it before submitting. I checked it against the ASan reproducer and the test above.
TransposeInts#44827