From b988f32c701760da8793f83f22f2043578e11b67 Mon Sep 17 00:00:00 2001 From: Rob N Date: Wed, 8 Mar 2023 09:05:14 +1100 Subject: 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 Reviewed-by: Brian Behlendorf Reviewed-by: Richard Yao Signed-off-by: Rob Norris Closes #14577 --- cmd/zdb/zdb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd/zdb') diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 6c8d73713..c6198ee26 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -3120,7 +3120,8 @@ zdb_load_key(objset_t *os) if (err != 0) fatal( "couldn't load encryption key for %s: %s", - encroot, strerror(err)); + encroot, err == ZFS_ERR_CRYPTO_NOTSUP ? + "crypto params not supported" : strerror(err)); ASSERT3U(dsl_dataset_get_keystatus(dd), ==, ZFS_KEYSTATUS_AVAILABLE); -- cgit v1.2.3