Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mysql-test/main/binlog_invalid_row_v2_tag.result
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FOUND 3 /[Uu]nknown [Ee]vent/ in invalid_row_v2_tag.sql
14 changes: 14 additions & 0 deletions mysql-test/main/binlog_invalid_row_v2_tag.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# MDEV-39485 Heap-buffer-overflow upon read in `Rows_log_event` constructor
#
# This binlog file contains a normal Format Description
# Event followed by 3 malformed v2 Write Rows Events:
# 1. A tag followed by no data
# 2. An undersized tagged data followed by an unrecognized tag
# 3. A tag followed by a length longer than the entire event

--source include/not_embedded.inc

--let SEARCH_PATTERN= [Uu]nknown [Ee]vent
--let SEARCH_FILE= $MYSQLTEST_VARDIR/tmp/invalid_row_v2_tag.sql
--exec $MYSQL_BINLOG --force-read --verbose std_data/binlog_invalid_row_v2_tag.001 > $SEARCH_FILE
--source include/search_pattern_in_file.inc
Binary file added mysql-test/std_data/binlog_invalid_row_v2_tag.001
Binary file not shown.
10 changes: 10 additions & 0 deletions mysql-test/suite/binlog/r/fdle_overflow.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SET @saved_dbug= @@GLOBAL.debug_dbug;
SET @@GLOBAL.debug_dbug=
'+d,truncate_fde_post_header_len,truncate_fde_used_checksum_alg';
FLUSH BINARY LOGS;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
SET @@GLOBAL.debug_dbug= '+d,truncate_fde_common_header_len';
FLUSH BINARY LOGS;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
SET @@GLOBAL.debug_dbug= @saved_dbug;
RESET MASTER;
8 changes: 8 additions & 0 deletions mysql-test/suite/binlog/r/unknown_log_event.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE t (a INT);
INSERT INTO t VALUES (0);
DROP TABLE t;
FLUSH BINARY LOGS;
#mariadb_binlog --debug=d,corrupt_table_map_colcnt_read --start-position=#binlog_start --stop-position=#binlog_stop #binlog_file 2>&1
FOUND 1 /CRC32 0x[[:xdigit:]]{8}.*\n# [Uu]nknown [Ee]vent/ in unknown_log_event.sql
#mariadb_binlog --debug=d,simulate_checksum_test_failure --stop-position=5 #binlog_file 2>&1
FOUND 1 /CRC32 0x[[:xdigit:]]{8}.*\n# [Uu]nknown [Ee]vent/ in unknown_log_event.sql
38 changes: 38 additions & 0 deletions mysql-test/suite/binlog/t/fdle_overflow.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--source include/have_debug.inc
--source include/have_binlog_format_mixed.inc # format-agnostic

# OOB read on malformed `Format_description_log_event`
#
# Verify that Format Description Events with truncated contents fails gracefully
# rather than underflow the post-header count and lead to buffer over-read.

SET @saved_dbug= @@GLOBAL.debug_dbug;


# MDEV-40366: `used_checksum_alg`

SET @@GLOBAL.debug_dbug=
'+d,truncate_fde_post_header_len,truncate_fde_used_checksum_alg';
FLUSH BINARY LOGS;

--let $binlog_file= query_get_value(SHOW BINLOG STATUS, File, 1)
--disable_query_log
--error ER_ERROR_WHEN_EXECUTING_COMMAND
--eval SHOW BINLOG EVENTS IN '$binlog_file'
--enable_query_log


# MDEV-40365: `common_header_len` & `post_header_len`

SET @@GLOBAL.debug_dbug= '+d,truncate_fde_common_header_len';
FLUSH BINARY LOGS;

--let $binlog_file= query_get_value(SHOW BINLOG STATUS, File, 1)
--disable_query_log
--error ER_ERROR_WHEN_EXECUTING_COMMAND
--eval SHOW BINLOG EVENTS IN '$binlog_file'
--enable_query_log

# Clean-up
SET @@GLOBAL.debug_dbug= @saved_dbug;
RESET MASTER;
37 changes: 37 additions & 0 deletions mysql-test/suite/binlog/t/unknown_log_event.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# MDEV-40674: Test `mariadb-binlog --force`'s Unknown event output
#
# Also: MDEV-40542
# MSAN use-of-uninitialized-value on Unknown_log_event::read_checksum_alg

--source include/have_debug.inc
--source include/have_binlog_format_row.inc # Testing with Table Map event

# Setup
CREATE TABLE t (a INT);
--let $binlog_file= query_get_value(SHOW BINLOG STATUS, File, 1)
--let $binlog_start= query_get_value(SHOW BINLOG STATUS, Position, 1)

# Generate an invalid Table Map event followed by an otherwise-valid Rows Event
INSERT INTO t VALUES (0);

--let $binlog_stop= query_get_value(SHOW BINLOG STATUS, Position, 1)
DROP TABLE t;
FLUSH BINARY LOGS;


--let SEARCH_FILE= $MYSQLTEST_VARDIR/tmp/unknown_log_event.sql
--let SEARCH_PATTERN= CRC32 0x[[:xdigit:]]{8}.*\\n# [Uu]nknown [Ee]vent
--let $mariadb_binlog= $MYSQL_BINLOG --result-file=$SEARCH_FILE --verify-binlog-checksum --force-read
--let $binlog_file= `SELECT CONCAT(@@datadir, '/$binlog_file')`

--echo #mariadb_binlog --debug=d,corrupt_table_map_colcnt_read --start-position=#binlog_start --stop-position=#binlog_stop #binlog_file 2>&1
--exec $mariadb_binlog --debug=d,corrupt_table_map_colcnt_read --start-position=$binlog_start --stop-position=$binlog_stop $binlog_file 2>&1
--source include/search_pattern_in_file.inc

# Test checksum failure
#
# Only test the first event since the rest of the binlog is unreadable
# without a valid Format Description, which is typically the first event.
--echo #mariadb_binlog --debug=d,simulate_checksum_test_failure --stop-position=5 #binlog_file 2>&1
--exec $mariadb_binlog --debug=d,simulate_checksum_test_failure --stop-position=5 $binlog_file 2>&1
--source include/search_pattern_in_file.inc
19 changes: 19 additions & 0 deletions mysql-test/suite/rpl/r/rpl_rotate_ev_overflow.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
SET @saved_dbug= @@GLOBAL.debug_dbug;
SET @@GLOBAL.debug_dbug= '+d,truncate_fde_post_header_len';
include/master-slave.inc
[connection master]
FLUSH BINARY LOGS;
CALL mtr.add_suppression('Found invalid event in binary log');
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
connection slave;
START SLAVE IO_THREAD;
CALL mtr.add_suppression('Slave I/O: Relay log write failure');
include/wait_for_slave_io_error.inc [errno=1595]
connection master;
SET @@GLOBAL.debug_dbug= @saved_dbug;
include/reset_master.inc
connection slave;
CHANGE MASTER TO master_use_gtid=SLAVE_POS;
SET @@GLOBAL.gtid_slave_pos='';
include/start_slave.inc
include/rpl_end.inc
51 changes: 51 additions & 0 deletions mysql-test/suite/rpl/t/rpl_rotate_ev_overflow.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# MDEV-40647 OOB read in IO Thread if the FDEv does not support Rotate Events

--source include/have_debug.inc
--source include/have_binlog_format_mixed.inc # should be format-agnostic

SET @saved_dbug= @@GLOBAL.debug_dbug;
SET @@GLOBAL.debug_dbug= '+d,truncate_fde_post_header_len';
--let $rpl_skip_start_slave= 1
# This setup will also RESET MASTER ...
--source include/master-slave.inc
# ... which means the binlog file is consistent.
--let $binlog_file= master-bin.000001

# Use a specific binlog position to avoid the
# test failing early from other metadata events
--let $binlog_start= query_get_value(SHOW BINLOG STATUS, Position, 1)
# Generate the Rotate Event
FLUSH BINARY LOGS;


# Control: SHOW BINLOG EVENTS fails as expected.
CALL mtr.add_suppression('Found invalid event in binary log');
--disable_query_log
--error ER_ERROR_WHEN_EXECUTING_COMMAND
--eval SHOW BINLOG EVENTS IN '$binlog_file' FROM $binlog_start
--enable_query_log

--connection slave
--disable_query_log
eval CHANGE MASTER TO master_use_gtid=NO,
master_log_file='$binlog_file', master_log_pos=$binlog_start;
--enable_query_log
START SLAVE IO_THREAD;
CALL mtr.add_suppression('Slave I/O: Relay log write failure');
# ER_SLAVE_RELAY_LOG_WRITE_FAILURE
--let $slave_io_errno= 1595
# Experiment: The IO thread should fail.
--source include/wait_for_slave_io_error.inc

# Clean-up
--connection master
SET @@GLOBAL.debug_dbug= @saved_dbug;
--source include/reset_master.inc

--connection slave
CHANGE MASTER TO master_use_gtid=SLAVE_POS; # restore the default
--disable_warnings
SET @@GLOBAL.gtid_slave_pos=''; # for good measure
--enable_warnings
--source include/start_slave.inc
--source include/rpl_end.inc
Loading