Skip to content

MDEV-40495 KEY_OP_SHIFT redo moves data past the page buffer - #5540

Open
KhaledR57 wants to merge 1 commit into
10.11from
10.11-MDEV-40495
Open

MDEV-40495 KEY_OP_SHIFT redo moves data past the page buffer#5540
KhaledR57 wants to merge 1 commit into
10.11from
10.11-MDEV-40495

Conversation

@KhaledR57

Copy link
Copy Markdown
Contributor

The KEY_OP_SHIFT branch of _ma_apply_redo_index() took the shift length straight from the redo record and used it to form a bmove() source and size, and to update page_length. The only guards were DBUG_ASSERTs, which are compiled out when DBUG_OFF is set. A corrupt record with a negative length could therefore move data from outside the page and wrap page_length.

Turn both asserts into runtime checks. The page offset must be set and inside the used page, the resulting page length must still fit the page, and for a negative shift the source must stay inside the used page too. The conditions are the ones the asserts already tested, so debug builds keep the same behaviour.

This also fixes MDEV-40496, which covers the page_length side of the same branch. The first check bounds it.

The test forges the logged shift length with two new debug keywords, corrupt_shift_down and corrupt_shift_up, then crashes the server so recovery has to replay the record.

The KEY_OP_SHIFT branch of _ma_apply_redo_index() took the shift length
straight from the redo record and used it to form a bmove() source and
size, and to update page_length. The only guards were DBUG_ASSERTs, which
are compiled out when DBUG_OFF is set. A corrupt record with a negative
length could therefore move data from outside the page and wrap
page_length.

Turn both asserts into runtime checks. The page offset must be set and
inside the used page, the resulting page length must still fit the page,
and for a negative shift the source must stay inside the used page too.
The conditions are the ones the asserts already tested, so debug builds
keep the same behaviour.

This also fixes MDEV-40496, which covers the page_length side of the same
branch. The first check bounds it.

The test forges the logged shift length with two new debug keywords,
corrupt_shift_down and corrupt_shift_up, 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