-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better handling for future crypto parameters #14577
Conversation
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. Signed-off-by: Rob Norris <[email protected]>
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. Signed-off-by: Rob Norris <[email protected]>
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. Signed-off-by: Rob Norris <[email protected]>
Signed-off-by: Rob Norris <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since all of these commits collectively relate to ZFS_ERR_CRYPTO_NOTSUP
, I think they should be squashed into a single commit. I realize the irony of saying this, given that I have been doing plenty of small commits lately, but keeping those separate at least serves a documentation purpose. Here, the documentation that we would get from separate commits is self explanatory based on where the changes are being made, so there is no reason for these changes to be kept in separate commits.
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 openzfs#14577
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 openzfs#14577
Motivation and Context
While testing #14249, I found a couple of places where OpenZFS doesn't cope well when presented with a dataset or stream that uses an unknown crypto suite. While its too late for those already deployed, we can at least make it that newer ZFS installs are able to fail gracefully rather than crash or do something weird.
Description
This introduces a new ioctl return,
ZFS_ERR_CRYPTO_NOTSUP
, and returns it when either we try to load an encryption key for a dataset that uses an unknown crypto suite (encryption
property value) or receive a raw backup stream that uses an unknown encryption key.zfs send
andzfs load-key
have been updated to produce a nicer error message in those cases.This is technically a very small ABI change, in that the
ZFS_IOC_RECV_NEW
andZFS_IOC_LOAD_KEY
can return a previously-unseen error code. Older versions of the ZFS-provided tools will handle these fine in their fallback error handlers, and I can't imagine any other users of those ioctls not having a similar fallback. If it was a problem,EINVAL
orENOTSUP
are both plausible alternatives though they do muddy the meaning of those a little.How Has This Been Tested?
Tested by hand by creating a dataset with
-o encryption=chacha20-poly1305
(#14249) and a backup stream from it, and then loading it / receiving it into a ZFS build at master (620a977) and with this PR.Before:
Before (with
--enable-debug
):After:
No additions to the test suite. I'm not really sure how to do this other than either checking in or cooking a dataset or backup stream under the hood, and that seems like it could be pretty brittle.
Types of changes
Checklist:
Signed-off-by
.