mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
Encryption Stability and On-Disk Format Fixes
The on-disk format for encrypted datasets protects not only the encrypted and authenticated blocks themselves, but also the order and interpretation of these blocks. In order to make this work while maintaining the ability to do raw sends, the indirect bps maintain a secure checksum of all the MACs in the block below it along with a few other fields that determine how the data is interpreted. Unfortunately, the current on-disk format erroneously includes some fields which are not portable and thus cannot support raw sends. It is not possible to easily work around this issue due to a separate and much smaller bug which causes indirect blocks for encrypted dnodes to not be compressed, which conflicts with the previous bug. In addition, the current code generates incompatible on-disk formats on big endian and little endian systems due to an issue with how block pointers are authenticated. Finally, raw send streams do not currently include dn_maxblkid when sending both the metadnode and normal dnodes which are needed in order to ensure that we are correctly maintaining the portable objset MAC. This patch zero's out the offending fields when computing the bp MAC and ensures that these MACs are always calculated in little endian order (regardless of the host system's byte order). This patch also registers an errata for the old on-disk format, which we detect by adding a "version" field to newly created DSL Crypto Keys. We allow datasets without a version (version 0) to only be mounted for read so that they can easily be migrated. We also now include dn_maxblkid in raw send streams to ensure the MAC can be maintained correctly. This patch also contains minor bug fixes and cleanups. Reviewed-by: Jorgen Lundman <lundman@lundman.net> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Signed-off-by: Tom Caputi <tcaputi@datto.com> Closes #6845 Closes #6864 Closes #7052
This commit is contained in:
committed by
Brian Behlendorf
parent
4c46b99d24
commit
ae76f45cda
@@ -36,6 +36,8 @@ struct zbookmark_phys;
|
||||
#define MASTER_KEY_MAX_LEN 32
|
||||
#define SHA512_HMAC_KEYLEN 64
|
||||
|
||||
#define ZIO_CRYPT_KEY_CURRENT_VERSION 1ULL
|
||||
|
||||
typedef enum zio_crypt_type {
|
||||
ZC_TYPE_NONE = 0,
|
||||
ZC_TYPE_CCM,
|
||||
@@ -64,6 +66,9 @@ typedef struct zio_crypt_key {
|
||||
/* encryption algorithm */
|
||||
uint64_t zk_crypt;
|
||||
|
||||
/* on-disk format version */
|
||||
uint64_t zk_version;
|
||||
|
||||
/* GUID for uniquely identifying this key. Not encrypted on disk. */
|
||||
uint64_t zk_guid;
|
||||
|
||||
@@ -104,9 +109,9 @@ int zio_crypt_key_get_salt(zio_crypt_key_t *key, uint8_t *salt_out);
|
||||
|
||||
int zio_crypt_key_wrap(crypto_key_t *cwkey, zio_crypt_key_t *key, uint8_t *iv,
|
||||
uint8_t *mac, uint8_t *keydata_out, uint8_t *hmac_keydata_out);
|
||||
int zio_crypt_key_unwrap(crypto_key_t *cwkey, uint64_t crypt, uint64_t guid,
|
||||
uint8_t *keydata, uint8_t *hmac_keydata, uint8_t *iv, uint8_t *mac,
|
||||
zio_crypt_key_t *key);
|
||||
int zio_crypt_key_unwrap(crypto_key_t *cwkey, uint64_t crypt, uint64_t version,
|
||||
uint64_t guid, uint8_t *keydata, uint8_t *hmac_keydata, uint8_t *iv,
|
||||
uint8_t *mac, zio_crypt_key_t *key);
|
||||
int zio_crypt_generate_iv(uint8_t *ivbuf);
|
||||
int zio_crypt_generate_iv_salt_dedup(zio_crypt_key_t *key, uint8_t *data,
|
||||
uint_t datalen, uint8_t *ivbuf, uint8_t *salt);
|
||||
|
||||
Reference in New Issue
Block a user