diff options
author | Eugene Kosov <claprix@yandex.ru> | 2020-03-16 11:10:01 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2020-03-16 17:27:51 +0300 |
commit | 7dafab7569e97355701da092b7edfda2f2d1810e (patch) | |
tree | 505d0b3cab70e9d0fe7d6ed2729ac327fd0898ba | |
parent | 0c2365c4e3c89c3b284315e19a7d95221b524868 (diff) | |
download | mariadb-git-7dafab7569e97355701da092b7edfda2f2d1810e.tar.gz |
MDEV-21949 key rotation for innodb_encrypt_log is not working in 10.5
log_t::has_encryption_key_rotation(): checks whether
key rotation is supported.
In a subsequent redo log format version, this key rotation
may be broken again.
-rw-r--r-- | storage/innobase/include/log0log.h | 12 | ||||
-rw-r--r-- | storage/innobase/log/log0crypt.cc | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 4aa9c83e32e..d8988f4a123 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -337,7 +337,7 @@ log_refresh_stats(void); #define LOG_BLOCK_KEY 4 /* encryption key version before LOG_BLOCK_CHECKSUM; - in log_t::FORMAT_ENC_10_4 only */ + after log_t::FORMAT_ENC_10_4 only */ #define LOG_BLOCK_CHECKSUM 4 /* 4 byte checksum of the log block contents; in InnoDB versions < 3.23.52 this did not contain the @@ -742,17 +742,21 @@ public: void set_check_flush_or_checkpoint(bool flag= true) { check_flush_or_checkpoint_.store(flag, std::memory_order_relaxed); } + bool has_encryption_key_rotation() const { + return log.format == FORMAT_ENC_10_4 || log.format == FORMAT_ENC_10_5; + } + /** @return the log block header + trailer size */ unsigned framing_size() const { - return log.format == FORMAT_ENC_10_4 + return has_encryption_key_rotation() ? LOG_BLOCK_HDR_SIZE + LOG_BLOCK_KEY + LOG_BLOCK_CHECKSUM : LOG_BLOCK_HDR_SIZE + LOG_BLOCK_CHECKSUM; } /** @return the log block payload size */ unsigned payload_size() const { - return log.format == FORMAT_ENC_10_4 + return has_encryption_key_rotation() ? OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM - LOG_BLOCK_KEY : OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM; @@ -760,7 +764,7 @@ public: /** @return the log block trailer offset */ unsigned trailer_offset() const { - return log.format == FORMAT_ENC_10_4 + return has_encryption_key_rotation() ? OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM - LOG_BLOCK_KEY : OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM; } diff --git a/storage/innobase/log/log0crypt.cc b/storage/innobase/log/log0crypt.cc index 7e350e37a9a..3bdc375b229 100644 --- a/storage/innobase/log/log0crypt.cc +++ b/storage/innobase/log/log0crypt.cc @@ -156,10 +156,10 @@ bool log_crypt(byte* buf, lsn_t lsn, ulint size, log_crypt_t op) byte* key_ver = &buf[OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_KEY - LOG_BLOCK_CHECKSUM]; const size_t dst_size - = log_sys.log.format == log_t::FORMAT_ENC_10_4 + = log_sys.has_encryption_key_rotation() ? sizeof dst - LOG_BLOCK_KEY : sizeof dst; - if (log_sys.log.format == log_t::FORMAT_ENC_10_4) { + if (log_sys.has_encryption_key_rotation()) { const uint key_version = info.key_version; switch (op) { case LOG_ENCRYPT_ROTATE_KEY: |