Skip to content

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
10.11from
10.11-MDEV-40493
Open

MDEV-40493 _ma_apply_redo_index: KEY_OP_MULTI_COPY memcpy uses unchecked offsets (page buffer OOB write)#5539
KhaledR57 wants to merge 1 commit into
10.11from
10.11-MDEV-40493

Conversation

@KhaledR57

Copy link
Copy Markdown
Contributor

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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant