[MDEV-12026] Support encrypted SPATIAL INDEX Created: 2017-02-08 Updated: 2023-09-27 Resolved: 2019-02-19 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Encryption, Storage Engine - InnoDB |
| Fix Version/s: | 10.4.3 |
| Type: | Task | Priority: | Blocker |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | encryption, gis, innodb | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
As noted in
|
| Comments |
| Comment by Marko Mäkelä [ 2018-11-14 ] | ||||||||||||||||||||||||||
|
A CREATE TABLE or ALTER TABLE of an encrypted table with SPATIAL INDEX was prevented in Surprises with unencrypted data (minimum bounding rectangles and PRIMARY KEY values) might be possible with innodb_encrypt_tables=ON. I think that we can do the following:
Thanks to the new page type code, the index pages should be unaccessible in earlier versions of MariaDB. As part of this fix, the creation of encrypted tables with SPATIAL INDEX must be re-enabled. | ||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2018-11-16 ] | ||||||||||||||||||||||||||
|
Open t1.ibd and check 4th page (root page of spatial index)
Primary key value "mysql" is visible to read even though encryption is enabled. | ||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2018-11-22 ] | ||||||||||||||||||||||||||
|
My idea of repurposing the fields "infimum" and "supremum" will not work with ROW_FORMAT=COMPRESSED tables, because those pages omit these records. But, the following fields are unused in all index pages except the root pages:
It turns out that even in root pages, the first 4 bytes of each field are redundant:
Let us repurpose the first 4 bytes of PAGE_BTR_SEG_TOP in the encrypted copy of the page, to store the encrypted 32-bit split sequence number (SSN). The encryption algorithm should be like this:
When decrypting, we would copy the SSN into the right place in the unencrypted page, and also restore the original contents:
It would be good to add
to the encryption code path. | ||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2018-12-28 ] | ||||||||||||||||||||||||||
|
We now have a patch that implements my suggestion above. This patch could theoretically backported to 10.2 and 10.3. If that patch were applied, an IMPORT TABLESPACE or a downgrade to an earlier version would seemingly succeed, but we would get crashes somewhere later when the encrypted spatial index is being accessed. During the recent work on Instead of shuffling bytes in multiple higher-level places of InnoDB, I think that the clean solution is to introduce a new encrypted file format, identified by a new flag in FSP_SPACE_FLAGS that would also prevent downgrading to earlier versions of MariaDB. This flag would indicate the following:
We’d introduce a new (and default) configuration parameter value The non-strict variant would open old tablespaces fine, but it would create new files with the new bit in FSP_SPACE_FLAGS set, preventing a downgrade. If compatibility with older MariaDB or MySQL versions is desired, then innodb_checksum_algorithm=crc32 can be set. In this case, any pre-existing new-checksum files would be opened fine, but they would keep using the new format. Any new created files would use the old format and the configured innodb_checksum_algorithm. Setting innodb_checksum_algorithm to something else than the default value (or its strict_ counterpart) would issue a deprecation warning, because we would want to remove the old algorithms and formats in some future release of MariaDB. To implement this, we’d have to do a few things differently when decrypting or encrypting pages, based on fil_space_t::flags. A member function could be introduced for those checks, something like this:
| ||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-02-19 ] | ||||||||||||||||||||||||||
|
This was pushed to MariaDB 10.4.3.
The follow-up task ROW_FORMAT=COMPRESSED tables will not use the new format. |