[MDEV-12926] encryption.innodb_onlinealter_encryption, encryption.innodb-bad-key-change failed in buildbot with valgrind Created: 2017-05-26  Updated: 2017-05-26  Resolved: 2017-05-26

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Encryption, Tests
Affects Version/s: 10.1.24
Fix Version/s: 10.1.24

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None


 Description   

http://buildbot.askmonty.org/buildbot/builders/work-amd64-valgrind/builds/10068/steps/test/logs/stdio

encryption.innodb_onlinealter_encryption 'cbc,innodb_plugin' w2 [ fail ]  Found warnings/errors in server log file!
        Test ended at 2017-05-26 10:00:21
 
==15231== Thread 26:
==15231== Syscall param pwrite64(buf) points to uninitialised byte(s)
==15231==    at 0x4E433E3: ??? (in /lib64/libpthread-2.18.so)
==15231==    by 0xC288FBE: os_file_pwrite(int, void const*, unsigned long, unsigned long) (os0file.cc:2708)
==15231==    by 0xC28930E: os_file_write_func(char const*, int, void const*, unsigned long, unsigned long) (os0file.cc:3166)
==15231==    by 0xC2F91F0: pfs_os_file_write_int_fd_func(char const*, int, void const*, unsigned long, unsigned long, char const*, unsigned long) (os0file.ic:411)
==15231==    by 0xC300990: row_merge_write(int, unsigned long, void const*, fil_space_crypt_t*, void*, unsigned long) (row0merge.cc:1019)
==15231==    by 0xC3030BF: row_merge_read_clustered_index(trx_t*, TABLE*, dict_table_t const*, dict_table_t const*, bool, dict_index_t**, dict_index_t*, fts_psort_t*, merge_file_t*, unsigned long const*, unsigned long, dtuple_t const*, unsigned long const*, unsigned long, ib_sequence_t&, unsigned char*, int*, float, fil_space_crypt_t*, unsigned char*) (row0merge.cc:2006)
==15231==    by 0xC308172: row_merge_build_indexes(trx_t*, dict_table_t*, dict_table_t*, bool, dict_index_t**, unsigned long const*, unsigned long, TABLE*, dtuple_t const*, unsigned long const*, unsigned long, ib_sequence_t&) (row0merge.cc:4106)
==15231==    by 0xC222D0E: ha_innodb::inplace_alter_table(TABLE*, Alter_inplace_info*) (handler0alter.cc:4249)
==15231==    by 0x6E9918: handler::ha_inplace_alter_table(TABLE*, Alter_inplace_info*) (handler.h:3704)
==15231==    by 0x6E1A77: mysql_inplace_alter_table(THD*, TABLE_LIST*, TABLE*, TABLE*, Alter_inplace_info*, enum_alter_inplace_result, MDL_request*, Alter_table_ctx*) (sql_table.cc:7149)
==15231==    by 0x6E6322: mysql_alter_table(THD*, char*, char*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool) (sql_table.cc:8963)
==15231==    by 0x75B98D: Sql_cmd_alter_table::execute(THD*) (sql_alter.cc:325)
==15231==  Address 0x19347000 is in a rw- anonymous segment
^ Found warnings in /mnt/data/buildot/maria-slave/work-opensuse-amd64/build/mysql-test/var/2/log/mysqld.1.err

encryption.innodb-bad-key-change 'cbc,innodb_plugin' w4 [ fail ]  Found warnings/errors in server log file!
        Test ended at 2017-05-26 10:11:02
line
==16217== Thread 22:
==16217== Syscall param pwrite64(buf) points to uninitialised byte(s)
==16217==    at 0x4E433E3: ??? (in /lib64/libpthread-2.18.so)
==16217==    by 0xC07EFBE: os_file_pwrite(int, void const*, unsigned long, unsigned long) (os0file.cc:2708)
==16217==    by 0xC07F30E: os_file_write_func(char const*, int, void const*, unsigned long, unsigned long) (os0file.cc:3166)
==16217==    by 0xC0EF1F0: pfs_os_file_write_int_fd_func(char const*, int, void const*, unsigned long, unsigned long, char const*, unsigned long) (os0file.ic:411)
==16217==    by 0xC0F6990: row_merge_write(int, unsigned long, void const*, fil_space_crypt_t*, void*, unsigned long) (row0merge.cc:1019)
==16217==    by 0xC0F90BF: row_merge_read_clustered_index(trx_t*, TABLE*, dict_table_t const*, dict_table_t const*, bool, dict_index_t**, dict_index_t*, fts_psort_t*, merge_file_t*, unsigned long const*, unsigned long, dtuple_t const*, unsigned long const*, unsigned long, ib_sequence_t&, unsigned char*, int*, float, fil_space_crypt_t*, unsigned char*) (row0merge.cc:2006)
==16217==    by 0xC0FE172: row_merge_build_indexes(trx_t*, dict_table_t*, dict_table_t*, bool, dict_index_t**, unsigned long const*, unsigned long, TABLE*, dtuple_t const*, unsigned long const*, unsigned long, ib_sequence_t&) (row0merge.cc:4106)
==16217==    by 0xC018D0E: ha_innodb::inplace_alter_table(TABLE*, Alter_inplace_info*) (handler0alter.cc:4249)
==16217==    by 0x6E9918: handler::ha_inplace_alter_table(TABLE*, Alter_inplace_info*) (handler.h:3704)
==16217==    by 0x6E1A77: mysql_inplace_alter_table(THD*, TABLE_LIST*, TABLE*, TABLE*, Alter_inplace_info*, enum_alter_inplace_result, MDL_request*, Alter_table_ctx*) (sql_table.cc:7149)
==16217==    by 0x6E6322: mysql_alter_table(THD*, char*, char*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool) (sql_table.cc:8963)
==16217==    by 0x75B98D: Sql_cmd_alter_table::execute(THD*) (sql_alter.cc:325)
==16217==  Address 0x17343000 is in a rw- anonymous segment
^ Found warnings in /mnt/data/buildot/maria-slave/work-opensuse-amd64/build/mysql-test/var/4/log/mysqld.1.err



 Comments   
Comment by Marko Mäkelä [ 2017-05-26 ]

This is a merge error.

This happens soon after the test restarts the server. The problem is that the first 4 bytes of the 1048576-byte buffer are uninitialized (and the rest of the buffer does not look like encrypted), containing strings "foobar" in plain text.

Side note: I would say that those first 4 bytes should not be allocated in the first place. Even if the temporary files are encrypted, the encryption metadata can be stored in memory. These temporary files are private to the thread that executes ALTER TABLE. A single random per-ALTER encryption key should suffice.

The first failing statement is:

ALTER TABLE t1 ADD COLUMN b int default 2;

Why is the data not encrypted? The call is using the unencrypted buf, not out_buf:

	ret = os_file_write_int_fd("(merge)", fd, buf, ofs, buf_len);

I introduced this error when merging the MySQL 5.6.36 merge from 10.0 to 10.1.

We were lucky that this was caught by Valgrind. The test is inadequate, because it does not execute any CHECK TABLE to ensure that the indexes were created correctly. Skipping encryption but not skipping decryption should make the temporary files look corrupted.

Generated at Thu Feb 08 08:01:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.