avoid out-of-bounds write in deserializer_t::pop_array#5644
Open
Keerthana-64 wants to merge 1 commit into
Open
avoid out-of-bounds write in deserializer_t::pop_array#5644Keerthana-64 wants to merge 1 commit into
Keerthana-64 wants to merge 1 commit into
Conversation
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.
Description
ASan, deserializing a crafted quantization entry into
group_dims_:quant_entry_t::deserializereadsgroup_ndimsfrom the byte stream and hands it todeserializer_t::pop_array, which copiessizeof(dim_t) * group_ndimsinto the fixedgroup_dims_(adims_t,DNNL_MAX_NDIMSentries). Nothing bounds the count, so a serialized entry whosegroup_ndimsexceedsDNNL_MAX_NDIMSwrites past the array with stream-supplied bytes. The bound belongs in the deserializer rather than the caller, sopop_arraynow takes the destination capacity and drops counts larger than it; the quant deserializer passesDNNL_MAX_NDIMS. Entries whose count fits the destination round-trip unchanged.Reproduce: build a stream of
group_ndims = 100followed by 100int64values and deserialize it into the 12-entrygroup_dims_. Before the change ASan reports the write above (704 bytes past the buffer); after it, the count is refused and the destination is left untouched. The new gtest intests/gtests/internals/test_serialization.cppcovers both the oversized-count rejection and a valid round-trip.Checklist
General
make testandmake test_benchdnn_*) pass locally for each commit?Bug fixes