Skip to content

MDEV-40494 KEY_OP_DEL_PREFIX subtracts unchecked length from page_length - #5579

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

MDEV-40494 KEY_OP_DEL_PREFIX subtracts unchecked length from page_length#5579
KhaledR57 wants to merge 1 commit into
10.11from
10.11-MDEV-40494

Conversation

@KhaledR57

Copy link
Copy Markdown
Contributor

The KEY_OP_DEL_PREFIX branch of _ma_apply_redo_index() subtracted the logged length from page_length and used the difference as a bmove() size, guarded only by a DBUG_ASSERT, which is compiled out when DBUG_OFF is set. A length larger than the used page underflows that size, and a length larger than page_length wraps page_length itself.

Turn the assert into a runtime check, written as an addition rather than the assert's subtraction, which underflows on a page shorter than its own header. A refused record takes the error path that was already there.

The test forges the logged length with corrupt_del_prefix, then crashes the server so recovery has to replay the record. The workload splits and merges index pages, this record comes from the underflow path, so plain inserts never produce one.

The KEY_OP_DEL_PREFIX branch of _ma_apply_redo_index() subtracted the
logged length from page_length and used the difference as a bmove() size,
guarded only by a DBUG_ASSERT, which is compiled out when DBUG_OFF is set.
A length larger than the used page underflows that size, and a
length larger than page_length wraps page_length itself.

Turn the assert into a runtime check, written as an addition rather than
the assert's subtraction, which underflows on a page shorter than its own
header. A refused record takes the error path that was already there.

The test forges the logged length with corrupt_del_prefix, then crashes the
server so recovery has to replay the record. The workload splits and merges
index pages: this record comes from the underflow path, so plain inserts
never produce one.
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