mariadb/mysql-test/suite
Sujatha 873cc1e77a MDEV-21839: Handle crazy offset to SHOW BINLOG EVENTS
Problem:
=======
SHOW BINLOG EVENTS FROM <"random"-pos> caused a variety of failures as
reported in MDEV-18046. They are fixed but that approach is not future-proof
as well as is not optimal to create extra check for being constructed event
parameters.

Analysis:
=========
"show binlog events from <pos>" code considers the user given position as a
valid event start position. The code starts reading data from this event start
position onwards and tries to map it to a set of known events. Each event has
a specific event structure and asserts have been added to ensure that, read
event data, satisfies the event specific requirements. When a random position
is supplied to "show binlog events command" the event structure specific
checks will fail and they result in assert.

For example: https://jira.mariadb.org/browse/MDEV-18046
In the bug description user executes CREATE TABLE/INSERT and ALTER SQL
commands.

When a crazy offset like "SHOW BINLOG EVENTS FROM 365" is provided code
assumes offset 365 as valid event begin and proceeds to EVENT_LEN_OFFSET reads
some random length and comes up with a crazy event which didn't exits in the
binary log. In this quoted example scenario, event read at offset 365 is
considered as "Update_rows_log_event", which is not present in binary log.
Since this is a random event its validation fails and code results in
assert/segmentation fault, as shown below.

mysqld: /data/src/10.4/sql/log_event.cc:10863: Rows_log_event::Rows_log_event(
    const char*, uint, const Format_description_log_event*):
    Assertion `var_header_len >= 2' failed.
    181220 15:27:02 [ERROR] mysqld got signal 6 ;
#7  0x00007fa0d96abee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055e744ef82de in Rows_log_event::Rows_log_event (this=0x7fa05800d390,
    buf=0x7fa05800d080 "", event_len=254, description_event=0x7fa058006d60) at
/data/src/10.4/sql/log_event.cc:10863
#9  0x000055e744f00cf8 in Update_rows_log_event::Update_rows_log_event

Since we are reading random data repeating the same command SHOW BINLOG EVENTS
FROM 365 produces different types of crashes with different events. MDEV-18046
reported 10 such crashes.

In order to avoid such scenarios user provided starting offset needs to be
validated for its correctness. Best way of doing this is to make use of
checksums if they are available. MDEV-18046 fix introduced the checksum based
validation.

The issue still remains in cases where binlog checksums are disabled. Please
find the following bug reports.

MDEV-22473: binlog.binlog_show_binlog_event_random_pos failed in buildbot,
            server crashed in read_log_event
MDEV-22455: Server crashes in Table_map_log_event,
            binlog.binlog_invalid_read_in_rotate failed in buildbot

Fix:
====
When binlog checksum is disabled, perform scan(via reading event by event), to
validate the requested FROM <pos> offset. Starting from offset 4 read the
event_length of next_event in the binary log. Using the next_event length
advance current offset to point to next event. Repeat this process till the
current offset is less than or equal to crazy offset. If current offset is
higher than crazy offset provide appropriate invalid input offset error.
2020-09-16 14:03:32 +05:30
..
archive MDEV-17297: stats.records=0 for a table of Archive engine when it has rows, when we run ANALYZE command 2019-04-18 23:12:43 +03:00
binlog MDEV-21839: Handle crazy offset to SHOW BINLOG EVENTS 2020-09-16 14:03:32 +05:30
binlog_encryption MDEV-16372 ER_BASE64_DECODE_ERROR upon replaying binary log via mysqlbinlog --verbose 2020-08-31 18:45:14 +03:00
csv Merge 10.0 into 10.1 2017-05-19 12:29:37 +03:00
encryption MDEV-16111 encryption.innodb_lotoftables failed in buildbot with wrong result 2019-06-12 19:08:49 +03:00
engines MDEV-23282 FLOAT(53,0) badly handles out-of-range values 2020-07-27 08:03:23 +04:00
federated Merge branch '10.0' into 10.1 2018-06-12 18:55:27 +03:00
funcs_1 mtr: use env for perl 2020-06-23 03:24:46 +02:00
funcs_2 mtr: use env for perl 2020-06-23 03:24:46 +02:00
galera Test fixes. 2020-06-24 09:38:54 +03:00
galera_3nodes MTR tests to test Galera fix for node joining over several configuration 2020-06-24 08:10:57 +03:00
handler MDEV-15945 --ps-protocol does not test some queries 2019-03-12 13:10:49 +01:00
heap Merge remote-tracking branch 'origin/5.5-galera' into 10.0-galera 2018-10-30 13:22:52 +02:00
innodb MDEV-19526 heap number overflow on innodb_page_size=64k 2020-08-12 18:21:53 +03:00
innodb_fts MDEV-22393 Corruption for SET GLOBAL innodb_ string variables 2020-04-28 16:09:07 +03:00
innodb_zip MDEV-14904 Backport innodb_default_row_format 2018-03-07 17:49:42 +02:00
jp
large_tests
maria MDEV-18496 Crash when Aria encryption is enabled but plugin not available 2020-07-29 14:56:24 +02:00
mariabackup MDEV-15662 mariabackup.huge_lsn fails sporadically with "log sequence number is in the future" 2020-07-14 13:24:37 +05:30
mtr/t
mtr2
multi_source MDEV-8874 Replication filters configured in my.cnf are ignored if slave reset and reconfigured 2019-06-27 09:54:20 +05:30
optimizer_unfixed_bugs Merge branch '10.0' into 10.1 2016-12-11 09:53:42 +01:00
parts MDEV-23375 parts.partition_debug fails when it's run after another test 2020-08-03 02:42:07 +03:00
percona
perfschema Merge branch 'merge-perfschema-5.6' into 10.1 2020-01-19 13:11:45 +01:00
perfschema_stress Update FSF Address 2019-05-11 21:29:06 +03:00
plugins MDEV-18686 Add option to PAM authentication plugin to allow case insensitive username matching 2019-04-24 16:06:54 +02:00
roles improve the error message for a dropped current role 2020-07-30 23:50:56 +02:00
rpl MDEV-17438 rpl.show_status_stop_slave_race-7126 fails with timeout on Windows 2020-09-11 15:35:32 +01:00
storage_engine Merge 10.0 into 10.1 2019-03-27 11:56:08 +02:00
stress Merge branch '10.0' into 10.1 2016-03-21 13:02:53 +01:00
sys_vars MDEV-20672 Inconsistent usage message for innodb_compression_algorithm 2020-08-12 18:35:21 +03:00
unit Merge branch '5.5' into 10.0 2018-06-21 00:44:10 +02:00
vcol MDEV-19232: Floating point precision / value comparison problem 2020-07-22 14:44:25 +05:30
wsrep MDEV-23440: mysql_tzinfo_to_sql to use transactions 2020-08-15 14:02:05 +10:00