aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs
diff options
context:
space:
mode:
authorRob N <[email protected]>2023-03-08 09:05:14 +1100
committerGitHub <[email protected]>2023-03-07 14:05:14 -0800
commitb988f32c701760da8793f83f22f2043578e11b67 (patch)
tree7c69988ae907867bd285b9081cdde4ef31f9be30 /lib/libzfs
parent12a240ac0b3b89e9210b3a2a539c1f74488e927d (diff)
Better handling for future crypto parameters
The intent is that this is like ENOTSUP, but specifically for when something can't be done because we have no support for the requested crypto parameters; eg unlocking a dataset or receiving a stream encrypted with a suite we don't support. Its not intended to be recoverable without upgrading ZFS itself. If the request could be made to work by enabling a feature or modifying some other configuration item, then some other code should be used. load-key: In the future we might have more crypto suites (ie new values for the `encryption` property. Right now trying to load a key on such a future crypto suite will look up suite parameters off the end of the crypto table, resulting in misbehaviour and/or crashes (or, with debug enabled, trip the assertion in `zio_crypt_key_unwrap`). Instead, lets check the value we got from the dataset, and if we can't handle it, abort early. recv: When receiving a raw stream encrypted with an unknown crypto suite, `zfs recv` would report a generic `invalid backup stream` (EINVAL). While technically correct, its not super helpful, so lets ship a more specific error code and message. Reviewed-by: Tino Reichardt <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Richard Yao <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #14577
Diffstat (limited to 'lib/libzfs')
-rw-r--r--lib/libzfs/libzfs_crypto.c5
-rw-r--r--lib/libzfs/libzfs_sendrecv.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/libzfs/libzfs_crypto.c b/lib/libzfs/libzfs_crypto.c
index 3ef883701..e8351b22f 100644
--- a/lib/libzfs/libzfs_crypto.c
+++ b/lib/libzfs/libzfs_crypto.c
@@ -1407,6 +1407,11 @@ try_again:
"Incorrect key provided for '%s'."),
zfs_get_name(zhp));
break;
+ case ZFS_ERR_CRYPTO_NOTSUP:
+ zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,
+ "'%s' uses an unsupported encryption suite."),
+ zfs_get_name(zhp));
+ break;
}
goto error;
}
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index 66a22e333..4b6e06df6 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -5161,6 +5161,12 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
"stream."));
(void) zfs_error(hdl, EZFS_BADVERSION, errbuf);
break;
+ case ZFS_ERR_CRYPTO_NOTSUP:
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "stream uses crypto parameters not compatible with "
+ "this pool"));
+ (void) zfs_error(hdl, EZFS_BADSTREAM, errbuf);
+ break;
case EDQUOT:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"destination %s space quota exceeded."), name);