aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTom Caputi <[email protected]>2017-11-08 14:12:59 -0500
committerBrian Behlendorf <[email protected]>2018-02-02 11:37:16 -0800
commitae76f45cda0e0857f99e53959cf71c7a5d66bd8b (patch)
treee1c3cabe0971272785a442d6fb627bf6ebd07148 /lib
parent4c46b99d24a6e71b3c72462c11cb051d0930ad60 (diff)
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Signed-off-by: Tom Caputi <[email protected]> Closes #6845 Closes #6864 Closes #7052
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/libzfs_crypto.c19
-rw-r--r--lib/libzfs/libzfs_status.c18
2 files changed, 20 insertions, 17 deletions
diff --git a/lib/libzfs/libzfs_crypto.c b/lib/libzfs/libzfs_crypto.c
index b1fac2f62..6ccee740f 100644
--- a/lib/libzfs/libzfs_crypto.c
+++ b/lib/libzfs/libzfs_crypto.c
@@ -1054,7 +1054,7 @@ zfs_crypto_load_key(zfs_handle_t *zhp, boolean_t noop, char *alt_keylocation)
}
try_again:
- /* fetching and deriving the key are correctible errors. set the flag */
+ /* fetching and deriving the key are correctable errors. set the flag */
correctible = B_TRUE;
/* get key material from key format and location */
@@ -1110,22 +1110,25 @@ try_again:
error:
zfs_error(zhp->zfs_hdl, EZFS_CRYPTOFAILED, errbuf);
- if (key_material != NULL)
+ if (key_material != NULL) {
free(key_material);
- if (key_data != NULL)
+ key_material = NULL;
+ }
+ if (key_data != NULL) {
free(key_data);
+ key_data = NULL;
+ }
/*
* Here we decide if it is ok to allow the user to retry entering their
* key. The can_retry flag will be set if the user is entering their
- * key from an interactive prompt. The correctible flag will only be
- * set if an error that occured could be corrected by retrying. Both
+ * key from an interactive prompt. The correctable flag will only be
+ * set if an error that occurred could be corrected by retrying. Both
* flags are needed to allow the user to attempt key entry again
*/
- if (can_retry && correctible && attempts <= MAX_KEY_PROMPT_ATTEMPTS) {
- attempts++;
+ attempts++;
+ if (can_retry && correctible && attempts < MAX_KEY_PROMPT_ATTEMPTS)
goto try_again;
- }
return (ret);
}
diff --git a/lib/libzfs/libzfs_status.c b/lib/libzfs/libzfs_status.c
index 320783523..f900ac723 100644
--- a/lib/libzfs/libzfs_status.c
+++ b/lib/libzfs/libzfs_status.c
@@ -352,6 +352,15 @@ check_status(nvlist_t *config, boolean_t isimport, zpool_errata_t *erratap)
return (ZPOOL_STATUS_REMOVED_DEV);
/*
+ * Informational errata available.
+ */
+ (void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_ERRATA, &errata);
+ if (errata) {
+ *erratap = errata;
+ return (ZPOOL_STATUS_ERRATA);
+ }
+
+ /*
* Outdated, but usable, version
*/
if (SPA_VERSION_IS_SUPPORTED(version) && version != SPA_VERSION)
@@ -382,15 +391,6 @@ check_status(nvlist_t *config, boolean_t isimport, zpool_errata_t *erratap)
}
}
- /*
- * Informational errata available.
- */
- (void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_ERRATA, &errata);
- if (errata) {
- *erratap = errata;
- return (ZPOOL_STATUS_ERRATA);
- }
-
return (ZPOOL_STATUS_OK);
}