mirror of
https://github.com/MariaDB/server.git
synced 2025-08-29 00:08:14 +03:00
The initial fix only covered a part of Mariabackup. This fix hardens InnoDB and XtraDB in a similar way, in order to reduce the probability of mistaking a corrupted encrypted page for a valid unencrypted one. This is based on work by Thirunarayanan Balathandayuthapani. fil_space_verify_crypt_checksum(): Assert that key_version!=0. Let the callers guarantee that. Now that we have this assertion, we also know that buf_page_is_zeroes() cannot hold. Also, remove all diagnostic output and related parameters, and let the relevant callers emit such messages. Last but not least, validate the post-encryption checksum according to the innodb_checksum_algorithm (only accepting one checksum for the strict variants), and no longer try to validate the page as if it was unencrypted. buf_page_is_zeroes(): Move to the compilation unit of the only callers, and declare static. xb_fil_cur_read(), buf_page_check_corrupt(): Add a condition before calling fil_space_verify_crypt_checksum(). This is a non-functional change. buf_dblwr_process(): Validate the page only as encrypted or unencrypted, but not both.
88 lines
2.8 KiB
Plaintext
88 lines
2.8 KiB
Plaintext
#
|
|
# MDEV-11759: Encryption code in MariaDB 10.1/10.2 causes compatibility problems
|
|
#
|
|
|
|
-- source include/have_innodb.inc
|
|
-- source include/have_file_key_management_plugin.inc
|
|
# Don't test under embedded
|
|
-- source include/not_embedded.inc
|
|
|
|
call mtr.add_suppression("InnoDB: Encrypted page \\d+:[36] in file .*test.t[123]\\.ibd looks corrupted; key_version=3221342974");
|
|
|
|
--disable_warnings
|
|
SET GLOBAL innodb_file_format = `Barracuda`;
|
|
SET GLOBAL innodb_file_per_table = ON;
|
|
set global innodb_compression_algorithm = 1;
|
|
--enable_warnings
|
|
|
|
--echo # Create and populate tables to be corrupted
|
|
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT,c char(200)) ENGINE=InnoDB encrypted=yes;
|
|
CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT,c char(200)) ENGINE=InnoDB row_format=compressed encrypted=yes;
|
|
CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes encrypted=yes;
|
|
|
|
BEGIN;
|
|
INSERT INTO t1 (b,c) VALUES ('corrupt me','secret');
|
|
--disable_query_log
|
|
--let $i = 100
|
|
while ($i)
|
|
{
|
|
INSERT INTO t1 (b,c) VALUES (REPEAT('abcabcabc', 100),'secretsecret');
|
|
dec $i;
|
|
}
|
|
--enable_query_log
|
|
|
|
INSERT INTO t1 (b,c) VALUES ('corrupt me','moresecretmoresecret');
|
|
INSERT INTO t2 select * from t1;
|
|
INSERT INTO t3 select * from t1;
|
|
COMMIT;
|
|
|
|
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
|
|
let MYSQLD_DATADIR=`select @@datadir`;
|
|
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
--echo # Backup tables before corrupting
|
|
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd.backup
|
|
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t2.ibd.backup
|
|
--copy_file $MYSQLD_DATADIR/test/t3.ibd $MYSQLD_DATADIR/test/t3.ibd.backup
|
|
|
|
--echo # Corrupt tables
|
|
|
|
perl;
|
|
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t1.ibd") or die "open";
|
|
binmode FILE;
|
|
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek";
|
|
print FILE pack("H*", "c001cafedeadb017");
|
|
close FILE or die "close";
|
|
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t2.ibd") or die "open";
|
|
binmode FILE;
|
|
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek";
|
|
print FILE pack("H*", "c001cafedeadb017");
|
|
close FILE or die "close";
|
|
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t3.ibd") or die "open";
|
|
binmode FILE;
|
|
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek";
|
|
print FILE pack("H*", "c001cafedeadb017");
|
|
close FILE or die "close";
|
|
EOF
|
|
|
|
--source include/start_mysqld.inc
|
|
|
|
--error ER_GET_ERRMSG
|
|
SELECT * FROM t1;
|
|
--error ER_GET_ERRMSG
|
|
SELECT * FROM t2;
|
|
--error ER_GET_ERRMSG
|
|
SELECT * FROM t3;
|
|
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
--echo # Restore the original tables
|
|
--move_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd
|
|
--move_file $MYSQLD_DATADIR/test/t2.ibd.backup $MYSQLD_DATADIR/test/t2.ibd
|
|
--move_file $MYSQLD_DATADIR/test/t3.ibd.backup $MYSQLD_DATADIR/test/t3.ibd
|
|
|
|
--source include/start_mysqld.inc
|
|
|
|
DROP TABLE t1,t2,t3;
|