MDEV-40493 _ma_apply_redo_index: KEY_OP_MULTI_COPY memcpy uses unchecked offsets (page buffer OOB write) - #5539
Open
KhaledR57 wants to merge 1 commit into
Open
MDEV-40493 _ma_apply_redo_index: KEY_OP_MULTI_COPY memcpy uses unchecked offsets (page buffer OOB write)#5539KhaledR57 wants to merge 1 commit into
KhaledR57 wants to merge 1 commit into
Conversation
…ked offsets The KEY_OP_MULTI_COPY branch passed full_length and every (to,from) pair from the redo record straight to memcpy(), guarded only by DBUG_ASSERTs. Those are compiled out when DBUG_OFF is set, and even in debug builds they check "to" and full_length against max_page_size separately, never their sum. A corrupt record could therefore copy past the page buffer into a neighbouring cached page, while recovery reported success. Add runtime bounds checks. full_length must fit in the page, the (to,from) list must stay inside the record and hold whole pairs, and each pair's larger offset plus full_length must stay in the page. A refused record takes the error path that was already there, which marks the table crashed and fails the redo phase. The test forces an RTREE split, the only producer of this record type, forges the logged "to" offset with corrupt_multi_copy_to debug keyword, then crashes the server so recovery has to replay the record.
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.
The
KEY_OP_MULTI_COPYbranch passedfull_lengthand every (to,from) pair from the redo record straight tomemcpy(), guarded only byDBUG_ASSERTs. Those are compiled out whenDBUG_OFFis set, and even in debug builds they check "to" andfull_lengthagainstmax_page_sizeseparately, never their sum. A corrupt record could therefore copy past the page buffer into a neighbouring cached page, while recovery reported success.Add runtime bounds checks.
full_lengthmust fit in the page, the (to,from) list must stay inside the record and hold whole pairs, and each pair's larger offset plusfull_lengthmust stay in the page. A refused record takes the error path that was already there, which marks the table crashed and fails the redo phase.The test forces an RTREE split, the only producer of this record type, forges the logged "to" offset with
corrupt_multi_copy_todebug keyword, then crashes the server so recovery has to replay the record.