Skip to content

Commit

Permalink
MDEV-18279 MLOG_FILE_WRITE_CRYPT_DATA fails to set the crypt_data->ty…
Browse files Browse the repository at this point in the history
…pe for tablespace.

Problem:
========
MLOG_FILE_WRITE_CRYPT_DATA redo log fails to apply type for
the crypt_data present in the space. While processing the double-write
buffer pages, page fails to decrypt. It leads to warning message.

Fix:
====
Set the type while parsing MLOG_FILE_WRITE_CRYPT_DATA redo log.
If type and length is of invalid type then mark it as corrupted.
  • Loading branch information
Thirunarayanan committed Jan 17, 2019
1 parent a84be48 commit ad376a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions storage/innobase/fil/fil0crypt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,12 @@ fil_parse_write_crypt_data(
uint len = mach_read_from_1(ptr);
ptr += 1;

ut_a(type == CRYPT_SCHEME_UNENCRYPTED ||
type == CRYPT_SCHEME_1); // only supported
if ((type != CRYPT_SCHEME_1 && type != CRYPT_SCHEME_UNENCRYPTED)
|| len != CRYPT_SCHEME_1_IV_LEN) {
*err = DB_CORRUPTION;
return NULL;
}

ut_a(len == CRYPT_SCHEME_1_IV_LEN); // only supported
uint min_key_version = mach_read_from_4(ptr);
ptr += 4;

Expand All @@ -551,6 +553,7 @@ fil_parse_write_crypt_data(
crypt_data->page0_offset = offset;
crypt_data->min_key_version = min_key_version;
crypt_data->encryption = encryption;
crypt_data->type = type;
memcpy(crypt_data->iv, ptr, len);
ptr += len;

Expand Down
9 changes: 6 additions & 3 deletions storage/xtradb/fil/fil0crypt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,12 @@ fil_parse_write_crypt_data(
uint len = mach_read_from_1(ptr);
ptr += 1;

ut_a(type == CRYPT_SCHEME_UNENCRYPTED ||
type == CRYPT_SCHEME_1); // only supported
if ((type != CRYPT_SCHEME_1 && type != CRYPT_SCHEME_UNENCRYPTED)
|| len != CRYPT_SCHEME_1_IV_LEN) {
*err = DB_CORRUPTION;
return NULL;
}

ut_a(len == CRYPT_SCHEME_1_IV_LEN); // only supported
uint min_key_version = mach_read_from_4(ptr);
ptr += 4;

Expand All @@ -551,6 +553,7 @@ fil_parse_write_crypt_data(
crypt_data->page0_offset = offset;
crypt_data->min_key_version = min_key_version;
crypt_data->encryption = encryption;
crypt_data->type = type;
memcpy(crypt_data->iv, ptr, len);
ptr += len;

Expand Down

0 comments on commit ad376a0

Please sign in to comment.