Hardware wrapped key support for QCom ICE and UFS core
Subsystems (14)
v7 cover Hardware wrapped key support for QCom ICE and UFS core
The previous iteration[1] has been on the list for many weeks without receiving any comments - neither positive nor negative. If there are no objections - could we start discussing how to make these patches go upstream for v6.14?
--
Hardware-wrapped keys are encrypted keys that can only be unwrapped (decrypted) and used by hardware - either by the inline encryption hardware itself, or by a dedicated hardware block that can directly provision keys to the inline encryption hardware. For more details, please see patches 1-3 in this series which extend the inline encryption docs with more information.
This series adds support for wrapped keys to the block layer, fscrypt and then build upwards from there by implementing relevant callbacks in QCom SCM driver, then the ICE driver and finally in UFS core and QCom layer.
Tested on sm8650-qrd.
How to test:
Use the wip-wrapped-keys branch from https://github.com/ebiggers/fscryptctl
to build a custom fscryptctl that supports generating wrapped keys.
Enable the following config options:CONFIG_BLK_INLINE_ENCRYPTION=yCONFIG_QCOM_INLINE_CRYPTO_ENGINE=mCONFIG_FS_ENCRYPTION_INLINE_CRYPT=yCONFIG_SCSI_UFS_CRYPTO=y
$ mkfs.ext4 -F -O encrypt,stable_inodes /dev/disk/by-partlabel/userdata $ mount /dev/disk/by-partlabel/userdata -o inlinecrypt /mnt $ fscryptctl generate_hw_wrapped_key /dev/disk/by-partlabel/userdata > /mnt/key.longterm $ fscryptctl prepare_hw_wrapped_key /dev/disk/by-partlabel/userdata < /mnt/key.longterm > /tmp/key.ephemeral $ KEYID=$(fscryptctl add_key --hw-wrapped-key < /tmp/key.ephemeral /mnt) $ rm -rf /mnt/dir $ mkdir /mnt/dir $ fscryptctl set_policy --hw-wrapped-key --iv-ino-lblk-64 "$KEYID" /mnt/dir $ dmesg > /mnt/dir/test.txt $ sync
Reboot the board
$ mount /dev/disk/by-partlabel/userdata -o inlinecrypt /mnt $ ls /mnt/dir $ fscryptctl prepare_hw_wrapped_key /dev/disk/by-partlabel/userdata < /mnt/key.longterm > /tmp/key.ephemeral $ KEYID=$(fscryptctl add_key --hw-wrapped-key < /tmp/key.ephemeral /mnt) $ fscryptctl set_policy --hw-wrapped-key --iv-ino-lblk-64 "$KEYID" /mnt/dir $ cat /mnt/dir/test.txt # File should now be decrypted
[1] https://lore.kernel.org/all/[email protected]/
---
Changes in v7:
- use a module param in conjunction with checking the platform support
at run-time to determine whether to use wrapped keys in the ICE driver
- various minor refactorings, replacing magic numbers with defines etc.
- fix kernel doc issues raised by autobuilders
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- add the wrapped key support from Eric Biggers to the series
- remove the new DT property from the series and instead query the at run-time rustZone to find out if wrapped keys are supported
- make the wrapped key support into a UFS capability, not a quirk
- improve kerneldocs
- improve and rework coding style in most patches
- improve and reformat commit messages
- simplify the offset calculation for CRYPTOCFG
- split out the DTS changes into a separate series
---
Bartosz Golaszewski (1):
firmware: qcom: scm: add a call for checking wrapped key support
Eric Biggers (4):
blk-crypto: add basic hardware-wrapped key support
blk-crypto: show supported key types in sysfs
blk-crypto: add ioctls to create and prepare hardware-wrapped keys
fscrypt: add support for hardware-wrapped keys
Gaurav Kashyap (12):
ice, ufs, mmc: use the blk_crypto_key struct when programming the key
firmware: qcom: scm: add a call for deriving the software secret
firmware: qcom: scm: add calls for creating, preparing and importing keys
soc: qcom: ice: add HWKM support to the ICE driver
soc: qcom: ice: add support for hardware wrapped keys
soc: qcom: ice: add support for generating, importing and preparing keys
ufs: core: add support for wrapped keys to UFS core
ufs: core: add support for deriving the software secret
ufs: core: add support for generating, importing and preparing keys
ufs: host: add support for wrapped keys in QCom UFS
ufs: host: add a callback for deriving software secrets and use it
ufs: host: add support for generating, importing and preparing wrapped keys
Documentation/ABI/stable/sysfs-block | 18 + Documentation/block/inline-encryption.rst | 245 +++++++++++++- Documentation/filesystems/fscrypt.rst | 154 ++++++++- Documentation/userspace-api/ioctl/ioctl-number.rst | 2 + block/blk-crypto-fallback.c | 5 +- block/blk-crypto-internal.h | 10 + block/blk-crypto-profile.c | 103 ++++++ block/blk-crypto-sysfs.c | 35 ++ block/blk-crypto.c | 194 ++++++++++- block/ioctl.c | 5 + drivers/firmware/qcom/qcom_scm.c | 233 +++++++++++++ drivers/firmware/qcom/qcom_scm.h | 4 + drivers/md/dm-table.c | 1 + drivers/mmc/host/cqhci-crypto.c | 9 +- drivers/mmc/host/cqhci.h | 2 + drivers/mmc/host/sdhci-msm.c | 6 +- drivers/soc/qcom/ice.c | 365 ++++++++++++++++++++- drivers/ufs/core/ufshcd-crypto.c | 86 ++++- drivers/ufs/host/ufs-qcom.c | 61 +++- fs/crypto/fscrypt_private.h | 71 +++- fs/crypto/hkdf.c | 4 +- fs/crypto/inline_crypt.c | 44 ++- fs/crypto/keyring.c | 124 +++++-- fs/crypto/keysetup.c | 54 ++- fs/crypto/keysetup_v1.c | 5 +- fs/crypto/policy.c | 11 +- include/linux/blk-crypto-profile.h | 73 +++++ include/linux/blk-crypto.h | 75 ++++- include/linux/firmware/qcom/qcom_scm.h | 8 + include/soc/qcom/ice.h | 18 +- include/uapi/linux/blk-crypto.h | 44 +++ include/uapi/linux/fs.h | 6 +- include/uapi/linux/fscrypt.h | 7 +- include/ufs/ufshcd.h | 21 ++ 34 files changed, 1968 insertions(+), 135 deletions(-)
---
base-commit: f486c8aa16b8172f63bddc70116a0c897a7f3f02
change-id: 20241128-wrapped-keys-c7a280792075
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
PATCH RESEND v7 1/17 blk-crypto: add basic hardware-wrapped key support
From: Eric Biggers <[email protected]>
To prevent keys from being compromised if an attacker acquires read access to kernel memory, some inline encryption hardware can accept keys which are wrapped by a per-boot hardware-internal key. This avoids needing to keep the raw keys in kernel memory, without limiting the number of keys that can be used. Such hardware also supports deriving a "software secret" for cryptographic tasks that can't be handled by inline encryption; this is needed for fscrypt to work properly.
To support this hardware, allow struct blk_crypto_key to represent a hardware-wrapped key as an alternative to a standard key, and make drivers set flags in struct blk_crypto_profile to indicate which types of keys they support. Also add the ->derive_sw_secret() low-level operation, which drivers supporting wrapped keys must implement.
For more information, see the detailed documentation which this patch adds to Documentation/block/inline-encryption.rst.
--- Documentation/block/inline-encryption.rst | 213 +++++++++++++++++++++++++++++- block/blk-crypto-fallback.c | 5 +- block/blk-crypto-internal.h | 1 + block/blk-crypto-profile.c | 46 +++++++ block/blk-crypto.c | 51 +++++-- drivers/md/dm-table.c | 1 + drivers/mmc/host/cqhci-crypto.c | 2 + drivers/ufs/core/ufshcd-crypto.c | 1 + fs/crypto/inline_crypt.c | 4 +- include/linux/blk-crypto-profile.h | 20 +++ include/linux/blk-crypto.h | 74 ++++++++++- 11 files changed, 394 insertions(+), 24 deletions(-)
Documentation/block/inline-encryption.rst +209 -4
@@ -77,10 +77,10 @@ Basic design ============ We introduce ``struct blk_crypto_key`` to represent an inline encryption key and -how it will be used. This includes the actual bytes of the key; the size of the -key; the algorithm and data unit size the key will be used with; and the number -of bytes needed to represent the maximum data unit number the key will be used -with. +how it will be used. This includes the type of the key (standard or +hardware-wrapped); the actual bytes of the key; the size of the key; the +algorithm and data unit size the key will be used with; and the number of bytes +needed to represent the maximum data unit number the key will be used with. We introduce ``struct bio_crypt_ctx`` to represent an encryption context. It contains a data unit number and a pointer to a blk_crypto_key. We add pointers
@@ -301,3 +301,208 @@ kernel will pretend that the device does not support hardware inline encryption When the crypto API fallback is enabled, this means that all bios with and encryption context will use the fallback, and IO will complete as usual. When the fallback is disabled, a bio with an encryption context will be failed. + +.. _hardware_wrapped_keys: + +Hardware-wrapped keys +===================== + +Motivation and threat model +--------------------------- + +Linux storage encryption (dm-crypt, fscrypt, eCryptfs, etc.) traditionally +relies on the raw encryption key(s) being present in kernel memory so that the +encryption can be performed. This traditionally isn't seen as a problem because +the key(s) won't be present during an offline attack, which is the main type of +attack that storage encryption is intended to protect from. + +However, there is an increasing desire to also protect users' data from other +types of attacks (to the extent possible), including: + +- Cold boot attacks, where an attacker with physical access to a system suddenly + powers it off, then immediately dumps the system memory to extract recently + in-use encryption keys, then uses these keys to decrypt user data on-disk. + +- Online attacks where the attacker is able to read kernel memory without fully + compromising the system, followed by an offline attack where any extracted + keys can be used to decrypt user data on-disk. An example of such an online + attack would be if the attacker is able to run some code on the system that + exploits a Meltdown-like vulnerability but is unable to escalate privileges. + +- Online attacks where the attacker fully compromises the system, but their data + exfiltration is significantly time-limited and/or bandwidth-limited, so in + order to completely exfiltrate the data they need to extract the encryption + keys to use in a later offline attack. + +Hardware-wrapped keys are a feature of inline encryption hardware that is +designed to protect users' data from the above attacks (to the extent possible), +without introducing limitations such as a maximum number of keys. + +Note that it is impossible to **fully** protect users' data from these attacks. +Even in the attacks where the attacker "just" gets read access to kernel memory, +they can still extract any user data that is present in memory, including +plaintext pagecache pages of encrypted files. The focus here is just on +protecting the encryption keys, as those instantly give access to **all** user +data in any following offline attack, rather than just some of it (where which +data is included in that "some" might not be controlled by the attacker). + +Solution overview +----------------- + +Inline encryption hardware typically has "keyslots" into which software can +program keys for the hardware to use; the contents of keyslots typically can't +be read back by software. As such, the above security goals could be achieved +if the kernel simply erased its copy of the key(s) after programming them into +keyslot(s) and thereafter only referred to them via keyslot number. + +However, that naive approach runs into the problem that it limits the number of +unlocked keys to the number of keyslots, which typically is a small number. In +cases where there is only one encryption key system-wide (e.g., a full-disk +encryption key), that can be tolerable. However, in general there can be many +logged-in users with many different keys, and/or many running applications with +application-specific encrypted storage areas. This is especially true if +file-based encryption (e.g. fscrypt) is being used. + +Thus, it is important for the kernel to still have a way to "remind" the +hardware about a key, without actually having the raw key itself. This would +ensure that the number of hardware keyslots only limits the number of active I/O +requests, not other things such as the number of logged-in users, the number of +running apps, or the number of encrypted storage areas that apps can create. + +Somewhat less importantly, it is also desirable that the raw keys are never +visible to software at all, even while being initially unlocked. This would +ensure that a read-only compromise of system memory will never allow a key to be +extracted to be used off-system, even if it occurs when a key is being unlocked. + +To solve all these problems, some vendors of inline encryption hardware have +made their hardware support *hardware-wrapped keys*. Hardware-wrapped keys +are encrypted keys that can only be unwrapped (decrypted) and used by hardware +-- either by the inline encryption hardware itself, or by a dedicated hardware +block that can directly provision keys to the inline encryption hardware. + +(We refer to them as "hardware-wrapped keys" rather than simply "wrapped keys" +to add some clarity in cases where there could be other types of wrapped keys, +such as in file-based encryption. Key wrapping is a commonly used technique.) + +The key which wraps (encrypts) hardware-wrapped keys is a hardware-internal key +that is never exposed to software; it is either a persistent key (a "long-term +wrapping key") or a per-boot key (an "ephemeral wrapping key"). The long-term +wrapped form of the key is what is initially unlocked, but it is erased from +memory as soon as it is converted into an ephemerally-wrapped key. In-use +hardware-wrapped keys are always ephemerally-wrapped, not long-term wrapped. + +As inline encryption hardware can only be used to encrypt/decrypt data on-disk, +the hardware also includes a level of indirection; it doesn't use the unwrapped +key directly for inline encryption, but rather derives both an inline encryption +key and a "software secret" from it. Software can use the "software secret" for +tasks that can't use the inline encryption hardware, such as filenames +encryption. The software secret is not protected from memory compromise. + +Key hierarchy +------------- + +Here is the key hierarchy for a hardware-wrapped key:: + + Hardware-wrapped key + | + | + <Hardware KDF> + | + ----------------------------- + | | + Inline encryption key Software secret + +The components are: + +- *Hardware-wrapped key*: a key for the hardware's KDF (Key Derivation + Function), in ephemerally-wrapped form. The key wrapping algorithm is a + hardware implementation detail that doesn't impact kernel operation, but a + strong authenticated encryption algorithm such as AES-256-GCM is recommended. + +- *Hardware KDF*: a KDF (Key Derivation Function) which the hardware uses to + derive subkeys after unwrapping the wrapped key. The hardware's choice of KDF + doesn't impact kernel operation, but it does need to be known for testing + purposes, and it's also assumed to have at least a 256-bit security strength. + All known hardware uses the SP800-108 KDF in Counter Mode with AES-256-CMAC, + with a particular choice of labels and contexts; new hardware should use this + already-vetted KDF. + +- *Inline encryption key*: a derived key which the hardware directly provisions + to a keyslot of the inline encryption hardware, without exposing it to + software. In all known hardware, this will always be an AES-256-XTS key. + However, in principle other encryption algorithms could be supported too. + Hardware must derive distinct subkeys for each supported encryption algorithm. + +- *Software secret*: a derived key which the hardware returns to software so + that software can use it for cryptographic tasks that can't use inline + encryption. This value is cryptographically isolated from the inline + encryption key, i.e. knowing one doesn't reveal the other. (The KDF ensures + this.) Currently, the software secret is always 32 bytes and thus is suitable + for cryptographic applications that require up to a 256-bit security strength. + Some use cases (e.g. full-disk encryption) won't require the software secret. + +Example: in the case of fscrypt, the fscrypt master key (the key that protects a +particular set of encrypted directories) is made hardware-wrapped. The inline +encryption key is used as the file contents encryption key, while the software +secret (rather than the master key directly) is used to key fscrypt's KDF +(HKDF-SHA512) to derive other subkeys such as filenames encryption keys. + +Note that currently this design assumes a single inline encryption key per +hardware-wrapped key, without any further key derivation. Thus, in the case of +fscrypt, currently hardware-wrapped keys are only compatible with the "inline +encryption optimized" settings, which use one file contents encryption key per +encryption policy rather than one per file. This design could be extended to +make the hardware derive per-file keys using per-file nonces passed down the +storage stack, and in fact some hardware already supports this; future work is +planned to remove this limitation by adding the corresponding kernel support. + +Kernel support +-------------- + +The inline encryption support of the kernel's block layer ("blk-crypto") has +been extended to support hardware-wrapped keys as an alternative to standard +keys, when hardware support is available. This works in the following way: + +- A ``key_types_supported`` field is added to the crypto capabilities in + ``struct blk_crypto_profile``. This allows device drivers to declare that + they support standard keys, hardware-wrapped keys, or both. + +- ``struct blk_crypto_key`` can now contain a hardware-wrapped key as an + alternative to a standard key; a ``key_type`` field is added to + ``struct blk_crypto_config`` to distinguish between the different key types. + This allows users of blk-crypto to en/decrypt data using a hardware-wrapped + key in a way very similar to using a standard key. + +- A new method ``blk_crypto_ll_ops::derive_sw_secret`` is added. Device drivers + that support hardware-wrapped keys must implement this method. Users of + blk-crypto can call ``blk_crypto_derive_sw_secret()`` to access this method. + +- The programming and eviction of hardware-wrapped keys happens via + ``blk_crypto_ll_ops::keyslot_program`` and + ``blk_crypto_ll_ops::keyslot_evict``, just like it does for standard keys. If + a driver supports hardware-wrapped keys, then it must handle hardware-wrapped + keys being passed to these methods. + +blk-crypto-fallback doesn't support hardware-wrapped keys. Therefore, +hardware-wrapped keys can only be used with actual inline encryption hardware. + +Testability +----------- + +Both the hardware KDF and the inline encryption itself are well-defined +algorithms that don't depend on any secrets other than the unwrapped key. +Therefore, if the unwrapped key is known to software, these algorithms can be +reproduced in software in order to verify the ciphertext that is written to disk +by the inline encryption hardware. + +However, the unwrapped key will only be known to software for testing if the +"import" functionality is used. Proper testing is not possible in the +"generate" case where the hardware generates the key itself. The correct +operation of the "generate" mode thus relies on the security and correctness of +the hardware RNG and its use to generate the key, as well as the testing of the +"import" mode as that should cover all parts other than the key generation. + +For an example of a test that verifies the ciphertext written to disk in the +"import" mode, see the fscrypt hardware-wrapped key tests in xfstests, or +`Android's vts_kernel_encryption_test +<https://android.googlesource.com/platform/test/vts-testcase/kernel/+/refs/heads/master/encryption/>`_.
block/blk-crypto-fallback.c +3 -2
@@ -87,7 +87,7 @@ static struct bio_set crypto_bio_split;* This is the key we set when evicting a keyslot. This *should* be the all 0's * key, but AES-XTS rejects that key, so we use some random bytes instead. */ -static u8 blank_key[BLK_CRYPTO_MAX_KEY_SIZE ]; +static u8 blank_key[BLK_CRYPTO_MAX_STANDARD_KEY_SIZE ];static void blk_crypto_fallback_evict_keyslot (unsigned int slot) {
@@ -539,7 +539,7 @@ static int blk_crypto_fallback_init(void)if (blk_crypto_fallback_inited)return 0 ; -get_random_bytes (blank_key,BLK_CRYPTO_MAX_KEY_SIZE ); +get_random_bytes (blank_key,sizeof (blank_key)); err =bioset_init (&crypto_bio_split,64 ,0 ,0 );if (err)
@@ -561,6 +561,7 @@ static int blk_crypto_fallback_init(void) blk_crypto_fallback_profile->ll_ops = blk_crypto_fallback_ll_ops; blk_crypto_fallback_profile->max_dun_bytes_supported =BLK_CRYPTO_MAX_IV_SIZE ; + blk_crypto_fallback_profile->key_types_supported =BLK_CRYPTO_KEY_TYPE_STANDARD ;/* All blk-crypto modes have a crypto API fallback. */ for (i =0 ; i <BLK_ENCRYPTION_MODE_MAX ; i++)
block/blk-crypto-internal.h +1 -0
@@ -14,6 +14,7 @@ struct blk_crypto_mode {const char *name;/* name of this mode, shown in sysfs */ const char *cipher_str;/* crypto API name (for fallback case) */ unsigned int keysize;/* key size in bytes */ +unsigned int security_strength;/* security strength in bytes */ unsigned int ivsize;/* iv size in bytes */ };
block/blk-crypto-profile.c +46 -0
79 lines not on this page · raw message
block/blk-crypto.c +41 -10
120 lines not on this page · raw message
drivers/md/dm-table.c +1 -0
@@ -1250,6 +1250,7 @@ static int dm_table_construct_crypto_profile(struct dm_table *t) profile->max_dun_bytes_supported =UINT_MAX ;memset (profile->modes_supported,0xFF ,sizeof (profile->modes_supported)); + profile->key_types_supported = ~0 ;for (i =0 ; i < t->num_targets; i++) {struct dm_target *ti =dm_table_get_target (t, i);
drivers/mmc/host/cqhci-crypto.c +2 -0
@@ -210,6 +210,8 @@ int cqhci_crypto_init(struct cqhci_host *cq_host)/* Unfortunately, CQHCI crypto only supports 32 DUN bits. */ profile->max_dun_bytes_supported =4 ; + profile->key_types_supported =BLK_CRYPTO_KEY_TYPE_STANDARD ; +/* * Cache all the crypto capabilities and advertise the supported crypto * modes and data unit sizes to the block layer.
drivers/ufs/core/ufshcd-crypto.c +1 -0
@@ -195,6 +195,7 @@ int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba) hba->crypto_profile.ll_ops = ufshcd_crypto_ops;/* UFS only supports 8 bytes for any DUN */ hba->crypto_profile.max_dun_bytes_supported =8 ; + hba->crypto_profile.key_types_supported =BLK_CRYPTO_KEY_TYPE_STANDARD ; hba->crypto_profile.dev = hba->dev;/*
fs/crypto/inline_crypt.c +3 -1
@@ -130,6 +130,7 @@ int fscrypt_select_encryption_impl(struct fscrypt_inode_info *ci) crypto_cfg.crypto_mode = ci->ci_mode->blk_crypto_mode; crypto_cfg.data_unit_size =1U << ci->ci_data_unit_bits; crypto_cfg.dun_bytes =fscrypt_get_dun_bytes (ci); + crypto_cfg.key_type =BLK_CRYPTO_KEY_TYPE_STANDARD ; devs =fscrypt_get_devices (sb, &num_devs);if (IS_ERR (devs))
@@ -166,7 +167,8 @@ int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key,if (!blk_key)return -ENOMEM ; - err =blk_crypto_init_key (blk_key, raw_key, crypto_mode, + err =blk_crypto_init_key (blk_key, raw_key, ci->ci_mode->keysize, +BLK_CRYPTO_KEY_TYPE_STANDARD , crypto_mode,fscrypt_get_dun_bytes (ci),1U << ci->ci_data_unit_bits);if (err) {
include/linux/blk-crypto-profile.h +20 -0
@@ -57,6 +57,20 @@ struct blk_crypto_ll_ops {int (*keyslot_evict)(struct blk_crypto_profile *profile,const struct blk_crypto_key *key,unsigned int slot); + +/** +* @derive_sw_secret: Derive the software secret from a hardware-wrapped +* key in ephemerally-wrapped form. +* +* This only needs to be implemented if BLK_CRYPTO_KEY_TYPE_HW_WRAPPED +* is supported. +* +* Must return 0 on success, -EBADMSG if the key is invalid, or another +* -errno code on other errors. +*/ +int (*derive_sw_secret)(struct blk_crypto_profile *profile, +const u8 *eph_key,size_t eph_key_size, +u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE ]); };/**
@@ -84,6 +98,12 @@ struct blk_crypto_profile {*/ unsigned int max_dun_bytes_supported; +/** +* @key_types_supported: A bitmask of the supported key types: +* BLK_CRYPTO_KEY_TYPE_STANDARD and/or BLK_CRYPTO_KEY_TYPE_HW_WRAPPED. +*/ +unsigned int key_types_supported; +/** * @modes_supported: Array of bitmasks that specifies whether each * combination of crypto mode and data unit size is supported.
include/linux/blk-crypto.h +67 -7
114 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH RESEND v7 2/17 blk-crypto: show supported key types in sysfs
In reply to Bartosz GolaszewskiFrom: Eric Biggers <[email protected]>
Add sysfs files that indicate which type(s) of keys are supported by the inline encryption hardware associated with a particular request queue:
/sys/block/$disk/queue/crypto/hw_wrapped_keys /sys/block/$disk/queue/crypto/standard_keys
Userspace can use the presence or absence of these files to decide what encyption settings to use.
Don't use a single key_type file, as devices might support both key types at the same time.
--- Documentation/ABI/stable/sysfs-block | 18 ++++++++++++++++++ block/blk-crypto-sysfs.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+)
Documentation/ABI/stable/sysfs-block +18 -0
@@ -229,6 +229,16 @@ Description: encryption, refer to Documentation/block/inline-encryption.rst. +What: /sys/block/<disk>/queue/crypto/hw_wrapped_keys +Contact: [email protected] +Description: + [RO] The presence of this file indicates that the device + supports hardware-wrapped inline encryption keys, i.e. key blobs + that can only be unwrapped and used by dedicated hardware. For + more information about hardware-wrapped inline encryption keys, + see Documentation/block/inline-encryption.rst. + + What: /sys/block/<disk>/queue/crypto/max_dun_bits Date: February 2022 Contact: [email protected]
@@ -267,6 +277,14 @@ Description: use with inline encryption. +What: /sys/block/<disk>/queue/crypto/standard_keys +Contact: [email protected] +Description: + [RO] The presence of this file indicates that the device + supports standard inline encryption keys, i.e. keys that are + managed in raw, plaintext form in software. + + What: /sys/block/<disk>/queue/dax Date: June 2016 Contact: [email protected]
block/blk-crypto-sysfs.c +35 -0
@@ -31,6 +31,13 @@ static struct blk_crypto_attr *attr_to_crypto_attr(struct attribute *attr) return container_of(attr, struct blk_crypto_attr, attr); } +static ssize_t hw_wrapped_keys_show (struct blk_crypto_profile *profile, +struct blk_crypto_attr *attr,char *page) +{ +/* Always show supported, since the file doesn't exist otherwise. */ +return sysfs_emit (page,"supported\n" ); +} +static ssize_t max_dun_bits_show (struct blk_crypto_profile *profile,struct blk_crypto_attr *attr,char *page) {
@@ -43,20 +50,48 @@ static ssize_t num_keyslots_show(struct blk_crypto_profile *profile,return sysfs_emit (page,"%u\n" , profile->num_slots); } +static ssize_t standard_keys_show (struct blk_crypto_profile *profile, +struct blk_crypto_attr *attr,char *page) +{ +/* Always show supported, since the file doesn't exist otherwise. */ +return sysfs_emit (page,"supported\n" ); +} +#define BLK_CRYPTO_RO_ATTR (_name) \ static struct blk_crypto_attr _name##_attr = __ATTR_RO(_name) +BLK_CRYPTO_RO_ATTR (hw_wrapped_keys);BLK_CRYPTO_RO_ATTR (max_dun_bits);BLK_CRYPTO_RO_ATTR (num_keyslots); +BLK_CRYPTO_RO_ATTR (standard_keys); + +static umode_t blk_crypto_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +struct blk_crypto_profile *profile =kobj_to_crypto_profile (kobj); +struct blk_crypto_attr *a =attr_to_crypto_attr (attr); + +if (a == &hw_wrapped_keys_attr && + !(profile->key_types_supported &BLK_CRYPTO_KEY_TYPE_HW_WRAPPED )) +return 0 ; +if (a == &standard_keys_attr && + !(profile->key_types_supported &BLK_CRYPTO_KEY_TYPE_STANDARD )) +return 0 ; + +return 0444 ; +}static struct attribute *blk_crypto_attrs[] = { + &hw_wrapped_keys_attr.attr, &max_dun_bits_attr.attr, &num_keyslots_attr.attr, + &standard_keys_attr.attr,NULL , };static const struct attribute_group blk_crypto_attr_group = { .attrs = blk_crypto_attrs, + .is_visible = blk_crypto_is_visible, };/*
Signature · 1 line
2.45.2
PATCH RESEND v7 3/17 blk-crypto: add ioctls to create and prepare hardware-wrapped keys
In reply to Bartosz GolaszewskiFrom: Eric Biggers <[email protected]>
Until this point, the kernel can use hardware-wrapped keys to do encryption if userspace provides one -- specifically a key in ephemerally-wrapped form. However, no generic way has been provided for userspace to get such a key in the first place.
Getting such a key is a two-step process. First, the key needs to be imported from a raw key or generated by the hardware, producing a key in long-term wrapped form. This happens once in the whole lifetime of the key. Second, the long-term wrapped key needs to be converted into ephemerally-wrapped form. This happens each time the key is "unlocked".
In Android, these operations are supported in a generic way through KeyMint, a userspace abstraction layer. However, that method is Android-specific and can't be used on other Linux systems, may rely on proprietary libraries, and also misleads people into supporting KeyMint features like rollback resistance that make sense for other KeyMint keys but don't make sense for hardware-wrapped inline encryption keys.
Therefore, this patch provides a generic kernel interface for these operations by introducing new block device ioctls:
- BLKCRYPTOIMPORTKEY: convert a raw key to long-term wrapped form.
- BLKCRYPTOGENERATEKEY: have the hardware generate a new key, then return it in long-term wrapped form.
- BLKCRYPTOPREPAREKEY: convert a key from long-term wrapped form to ephemerally-wrapped form.
These ioctls are implemented using new operations in blk_crypto_ll_ops.
--- Documentation/block/inline-encryption.rst | 32 +++++ Documentation/userspace-api/ioctl/ioctl-number.rst | 2 + block/blk-crypto-internal.h | 9 ++ block/blk-crypto-profile.c | 57 ++++++++ block/blk-crypto.c | 143 +++++++++++++++++++++ block/ioctl.c | 5 + include/linux/blk-crypto-profile.h | 53 ++++++++ include/linux/blk-crypto.h | 1 + include/uapi/linux/blk-crypto.h | 44 +++++++ include/uapi/linux/fs.h | 6 +- 10 files changed, 348 insertions(+), 4 deletions(-)
Documentation/block/inline-encryption.rst +32 -0
@@ -486,6 +486,38 @@ keys, when hardware support is available. This works in the following way: blk-crypto-fallback doesn't support hardware-wrapped keys. Therefore, hardware-wrapped keys can only be used with actual inline encryption hardware. +All the above deals with hardware-wrapped keys in ephemerally-wrapped form only. +To get such keys in the first place, new block device ioctls have been added to +provide a generic interface to creating and preparing such keys: + +- ``BLKCRYPTOIMPORTKEY`` converts a raw key to long-term wrapped form. It takes + in a pointer to a ``struct blk_crypto_import_key_arg``. The caller must set + ``raw_key_ptr`` and ``raw_key_size`` to the pointer and size (in bytes) of the + raw key to import. On success, ``BLKCRYPTOIMPORTKEY`` returns 0 and writes + the resulting long-term wrapped key blob to the buffer pointed to by + ``lt_key_ptr``, which is of maximum size ``lt_key_size``. It also updates + ``lt_key_size`` to be the actual size of the key. On failure, it returns -1 + and sets errno. + +- ``BLKCRYPTOGENERATEKEY`` is like ``BLKCRYPTOIMPORTKEY``, but it has the + hardware generate the key instead of importing one. It takes in a pointer to + a ``struct blk_crypto_generate_key_arg``. + +- ``BLKCRYPTOPREPAREKEY`` converts a key from long-term wrapped form to + ephemerally-wrapped form. It takes in a pointer to a ``struct + blk_crypto_prepare_key_arg``. The caller must set ``lt_key_ptr`` and + ``lt_key_size`` to the pointer and size (in bytes) of the long-term wrapped + key blob to convert. On success, ``BLKCRYPTOPREPAREKEY`` returns 0 and writes + the resulting ephemerally-wrapped key blob to the buffer pointed to by + ``eph_key_ptr``, which is of maximum size ``eph_key_size``. It also updates + ``eph_key_size`` to be the actual size of the key. On failure, it returns -1 + and sets errno. + +Userspace needs to use either ``BLKCRYPTOIMPORTKEY`` or ``BLKCRYPTOGENERATEKEY`` +once to create a key, and then ``BLKCRYPTOPREPAREKEY`` each time the key is +unlocked and added to the kernel. Note that these ioctls have no relevance for +standard keys; they are only for hardware-wrapped keys. + Testability -----------
Documentation/userspace-api/ioctl/ioctl-number.rst +2 -0
@@ -85,6 +85,8 @@ Code Seq# Include File Comments 0x10 20-2F arch/s390/include/uapi/asm/hypfs.h 0x12 all linux/fs.h BLK* ioctls linux/blkpg.h + linux/blkzoned.h + linux/blk-crypto.h 0x15 all linux/fs.h FS_IOC_* ioctls 0x1b all InfiniBand Subsystem <http://infiniband.sourceforge.net/>
block/blk-crypto-internal.h +9 -0
@@ -83,6 +83,9 @@ int __blk_crypto_evict_key(struct blk_crypto_profile *profile,bool __blk_crypto_cfg_supported (struct blk_crypto_profile *profile,const struct blk_crypto_config *cfg); +int blk_crypto_ioctl (struct block_device *bdev,unsigned int cmd, +void __user *argp); +#else /* CONFIG_BLK_INLINE_ENCRYPTION */ static inline int blk_crypto_sysfs_register (struct gendisk *disk)
@@ -130,6 +133,12 @@ static inline bool blk_crypto_rq_has_keyslot(struct request *rq) return false; } +static inline int blk_crypto_ioctl (struct block_device *bdev,unsigned int cmd, +void __user *argp) +{ +return -ENOTTY ; +} +#endif /* CONFIG_BLK_INLINE_ENCRYPTION */ void __bio_crypt_advance (struct bio *bio,unsigned int bytes);
block/blk-crypto-profile.c +57 -0
63 lines not on this page · raw message
block/blk-crypto.c +143 -0
146 lines not on this page · raw message
block/ioctl.c +5 -0
@@ -15,6 +15,7 @@#include <linux/io_uring/cmd.h> #include <uapi/linux/blkdev.h> #include "blk.h" +#include "blk-crypto-internal.h" static int blkpg_do_ioctl (struct block_device *bdev,struct blkpg_partition __user *upart,int op)
@@ -620,6 +621,10 @@ static int blkdev_common_ioctl(struct block_device *bdev, blk_mode_t mode,case BLKTRACESTOP :case BLKTRACETEARDOWN :return blk_trace_ioctl (bdev, cmd, argp); +case BLKCRYPTOIMPORTKEY : +case BLKCRYPTOGENERATEKEY : +case BLKCRYPTOPREPAREKEY : +return blk_crypto_ioctl (bdev, cmd, argp);case IOC_PR_REGISTER :return blkdev_pr_register (bdev, mode, argp);case IOC_PR_RESERVE :
include/linux/blk-crypto-profile.h +53 -0
65 lines not on this page · raw message
include/linux/blk-crypto.h +1 -0
@@ -7,6 +7,7 @@#define __LINUX_BLK_CRYPTO_H#include <linux/types.h> +#include <uapi/linux/blk-crypto.h> enum blk_crypto_mode_num {BLK_ENCRYPTION_MODE_INVALID ,
include/uapi/linux/blk-crypto.h new file +44 -0
44 lines not on this page · raw message
include/uapi/linux/fs.h +2 -4
@@ -203,10 +203,8 @@ struct fsxattr {#define BLKROTATIONAL _IO(0x12,126)#define BLKZEROOUT _IO(0x12,127)#define BLKGETDISKSEQ _IOR(0x12,128,__u64) -/* -* A jump here: 130-136 are reserved for zoned block devices -* (see uapi/linux/blkzoned.h) -*/ +/* 130-136 are used by zoned block device ioctls (uapi/linux/blkzoned.h) */ +/* 137-141 are used by blk-crypto ioctls (uapi/linux/blk-crypto.h) */ #define BMAP_IOCTL 1/* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1)/* bmap access */
Signature · 1 line
2.45.2
PATCH RESEND v7 4/17 fscrypt: add support for hardware-wrapped keys
In reply to Bartosz GolaszewskiFrom: Eric Biggers <[email protected]>
Add support for hardware-wrapped keys to fscrypt. Such keys are protected from certain attacks, such as cold boot attacks. For more information, see the "Hardware-wrapped keys" section of Documentation/block/inline-encryption.rst.
To support hardware-wrapped keys in fscrypt, we allow the fscrypt master keys to be hardware-wrapped, and we allow encryption policies to be flagged as needing a hardware-wrapped key. File contents encryption is done by passing the wrapped key to the inline encryption hardware via blk-crypto. Other fscrypt operations such as filenames encryption continue to be done by the kernel, using the "software secret" which the hardware derives. For more information, see the documentation which this patch adds to Documentation/filesystems/fscrypt.rst.
Note that this feature doesn't require any filesystem-specific changes. However it does depend on inline encryption support, and thus currently it is only applicable to ext4 and f2fs.
This feature is intentionally not UAPI or on-disk format compatible with the version of this feature in the Android Common Kernels, as that version was meant as a temporary solution and it took some shortcuts. Once upstreamed, this new version should be used going forwards.
This patch has been heavily rewritten from the original version by Gaurav Kashyap <[email protected]> and
Barani Muthukumaran <[email protected]>.
--- Documentation/filesystems/fscrypt.rst | 154 ++++++++++++++++++++++++++++++---- fs/crypto/fscrypt_private.h | 71 ++++++++++++++-- fs/crypto/hkdf.c | 4 +- fs/crypto/inline_crypt.c | 46 ++++++++-- fs/crypto/keyring.c | 124 +++++++++++++++++++-------- fs/crypto/keysetup.c | 54 +++++++++++- fs/crypto/keysetup_v1.c | 5 +- fs/crypto/policy.c | 11 ++- include/uapi/linux/fscrypt.h | 7 +- 9 files changed, 402 insertions(+), 74 deletions(-)
Documentation/filesystems/fscrypt.rst +137 -17
@@ -70,7 +70,7 @@ Online attacks -------------- fscrypt (and storage encryption in general) can only provide limited -protection, if any at all, against online attacks. In detail: +protection against online attacks. In detail: Side-channel attacks ~~~~~~~~~~~~~~~~~~~~
@@ -99,16 +99,23 @@ Therefore, any encryption-specific access control checks would merely be enforced by kernel *code* and therefore would be largely redundant with the wide variety of access control mechanisms already available.) -Kernel memory compromise -~~~~~~~~~~~~~~~~~~~~~~~~ +Read-only kernel memory compromise +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -An attacker who compromises the system enough to read from arbitrary -memory, e.g. by mounting a physical attack or by exploiting a kernel -security vulnerability, can compromise all encryption keys that are -currently in use. +Unless `hardware-wrapped keys`_ are used, an attacker who gains the +ability to read from arbitrary kernel memory, e.g. by mounting a +physical attack or by exploiting a kernel security vulnerability, can +compromise all fscrypt keys that are currently in-use. This also +extends to cold boot attacks; if the system is suddenly powered off, +keys the system was using may remain in memory for a short time. -However, fscrypt allows encryption keys to be removed from the kernel, -which may protect them from later compromise. +However, if hardware-wrapped keys are used, then the fscrypt master +keys and file contents encryption keys (but not other types of fscrypt +subkeys such as filenames encryption keys) are protected from +compromises of arbitrary kernel memory. + +In addition, fscrypt allows encryption keys to be removed from the +kernel, which may protect them from later compromise. In more detail, the FS_IOC_REMOVE_ENCRYPTION_KEY ioctl (or the FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS ioctl) can wipe a master
@@ -145,6 +152,24 @@ However, these ioctls have some limitations: accelerator hardware (if used by the crypto API to implement any of the algorithms), or in other places not explicitly considered here. +Full system compromise +~~~~~~~~~~~~~~~~~~~~~~ + +An attacker who gains "root" access and/or the ability to execute +arbitrary kernel code can freely exfiltrate data that is protected by +any in-use fscrypt keys. Thus, usually fscrypt provides no meaningful +protection in this scenario. (Data that is protected by a key that is +absent throughout the entire attack remains protected, modulo the +limitations of key removal mentioned above in the case where the key +was removed prior to the attack.) + +However, if `hardware-wrapped keys`_ are used, such attackers will be +unable to exfiltrate the master keys or file contents keys in a form +that will be usable after the system is powered off. This may be +useful if the attacker is significantly time-limited and/or +bandwidth-limited, so they can only exfiltrate some data and need to +rely on a later offline attack to exfiltrate the rest of it. + Limitations of v1 policies ~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -171,6 +196,11 @@ policies on all new encrypted directories. Key hierarchy ============= +Note: this section assumes the use of standard keys (i.e. "software +keys") rather than hardware-wrapped keys. The use of hardware-wrapped +keys modifies the key hierarchy slightly. For details, see the +`Hardware-wrapped keys`_ section. + Master Keys -----------
@@ -614,6 +644,8 @@ This structure must be initialized as follows: policies`_. - FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32: See `IV_INO_LBLK_32 policies`_. + - FSCRYPT_POLICY_FLAG_HW_WRAPPED_KEY: This flag denotes that this + policy uses a hardware-wrapped key. See `Hardware-wrapped keys`_. v1 encryption policies only support the PAD_* and DIRECT_KEY flags. The other flags are only supported by v2 encryption policies.
@@ -836,7 +868,8 @@ a pointer to struct fscrypt_add_key_arg, defined as follows:: struct fscrypt_key_specifier key_spec; __u32 raw_size; __u32 key_id; - __u32 __reserved[8]; + __u32 flags; + __u32 __reserved[7]; __u8 raw[]; };
@@ -855,7 +888,7 @@ a pointer to struct fscrypt_add_key_arg, defined as follows:: struct fscrypt_provisioning_key_payload { __u32 type; - __u32 __reserved; + __u32 flags; __u8 raw[]; };
@@ -883,6 +916,12 @@ as follows: Alternatively, if ``key_id`` is nonzero, this field must be 0, since in that case the size is implied by the specified Linux keyring key. +- ``flags`` contains optional flags from ``<linux/fscrypt.h>``: + + - FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED: This denotes that the key is a + hardware-wrapped key. See `Hardware-wrapped keys`_. This flag + can't be used if FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR is used. + - ``key_id`` is 0 if the raw key is given directly in the ``raw`` field. Otherwise ``key_id`` is the ID of a Linux keyring key of type "fscrypt-provisioning" whose payload is
@@ -924,6 +963,8 @@ FS_IOC_ADD_ENCRYPTION_KEY can fail with the following errors: caller does not have the CAP_SYS_ADMIN capability in the initial user namespace; or the raw key was specified by Linux key ID but the process lacks Search permission on the key. +- ``EBADMSG``: FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED was specified, but the + key isn't a valid hardware-wrapped key - ``EDQUOT``: the key quota for this user would be exceeded by adding the key - ``EINVAL``: invalid key size or key specifier type, or reserved bits
@@ -935,7 +976,9 @@ FS_IOC_ADD_ENCRYPTION_KEY can fail with the following errors: - ``ENOTTY``: this type of filesystem does not implement encryption - ``EOPNOTSUPP``: the kernel was not configured with encryption support for this filesystem, or the filesystem superblock has not - had encryption enabled on it + had encryption enabled on it, or FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED was + specified but the filesystem and/or the hardware doesn't support + hardware-wrapped keys Legacy method ~~~~~~~~~~~~~
@@ -998,9 +1041,8 @@ or removed by non-root users. These ioctls don't work on keys that were added via the legacy process-subscribed keyrings mechanism. -Before using these ioctls, read the `Kernel memory compromise`_ -section for a discussion of the security goals and limitations of -these ioctls. +Before using these ioctls, read the `Online attacks`_ section for a +discussion of the security goals and limitations of these ioctls. FS_IOC_REMOVE_ENCRYPTION_KEY ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1320,7 +1362,8 @@ inline encryption hardware doesn't have the needed crypto capabilities (e.g. support for the needed encryption algorithm and data unit size) and where blk-crypto-fallback is unusable. (For blk-crypto-fallback to be usable, it must be enabled in the kernel configuration with -CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK=y.) +CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK=y, and the file must be +protected by a standard key rather than a hardware-wrapped key.) Currently fscrypt always uses the filesystem block size (which is usually 4096 bytes) as the data unit size. Therefore, it can only use
@@ -1328,7 +1371,84 @@ inline encryption hardware that supports that data unit size. Inline encryption doesn't affect the ciphertext or other aspects of the on-disk format, so users may freely switch back and forth between -using "inlinecrypt" and not using "inlinecrypt". +using "inlinecrypt" and not using "inlinecrypt". An exception is that +files that are protected by a hardware-wrapped key can only be +encrypted/decrypted by the inline encryption hardware and therefore +can only be accessed when the "inlinecrypt" mount option is used. For +more information about hardware-wrapped keys, see below. + +Hardware-wrapped keys +--------------------- + +fscrypt supports using *hardware-wrapped keys* when the inline +encryption hardware supports it. Such keys are only present in kernel +memory in wrapped (encrypted) form; they can only be unwrapped +(decrypted) by the inline encryption hardware and are temporally bound +to the current boot. This prevents the keys from being compromised if +kernel memory is leaked. This is done without limiting the number of +keys that can be used and while still allowing the execution of +cryptographic tasks that are tied to the same key but can't use inline +encryption hardware, e.g. filenames encryption. + +Note that hardware-wrapped keys aren't specific to fscrypt; they are a +block layer feature (part of *blk-crypto*). For more details about +hardware-wrapped keys, see the block layer documentation at +:ref:`Documentation/block/inline-encryption.rst +<hardware_wrapped_keys>`. Below, we just focus on the details of how +fscrypt can use hardware-wrapped keys. + +fscrypt supports hardware-wrapped keys by allowing the fscrypt master +keys to be hardware-wrapped keys as an alternative to standard keys. +To add a hardware-wrapped key with `FS_IOC_ADD_ENCRYPTION_KEY`_, +userspace must specify FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED in the +``flags`` field of struct fscrypt_add_key_arg and also in the +``flags`` field of struct fscrypt_provisioning_key_payload when +applicable. The key must be in ephemerally-wrapped form, not +long-term wrapped form. + +To specify that files will be protected by a hardware-wrapped key, +userspace must specify FSCRYPT_POLICY_FLAG_HW_WRAPPED_KEY in the +encryption policy. (Note that this flag is somewhat redundant, as the +encryption policy also contains the key identifier, and +hardware-wrapped keys and standard keys will have different key +identifiers. However, it is sometimes helpful to make it explicit +that an encryption policy is supposed to use a hardware-wrapped key.) + +Some limitations apply. First, files protected by a hardware-wrapped +key are tied to the system's inline encryption hardware. Therefore +they can only be accessed when the "inlinecrypt" mount option is used, +and they can't be included in portable filesystem images. Second, +currently the hardware-wrapped key support is only compatible with +`IV_INO_LBLK_64 policies`_ and `IV_INO_LBLK_32 policies`_, as it +assumes that there is just one file contents encryption key per +fscrypt master key rather than one per file. Future work may address +this limitation by passing per-file nonces down the storage stack to +allow the hardware to derive per-file keys. + +Implementation-wise, to encrypt/decrypt the contents of files that are +protected by a hardware-wrapped key, fscrypt uses blk-crypto, +attaching the hardware-wrapped key to the bio crypt contexts. As is +the case with standard keys, the block layer will program the key into +a keyslot when it isn't already in one. However, when programming a +hardware-wrapped key, the hardware doesn't program the given key +directly into a keyslot but rather unwraps it (using the hardware's +ephemeral wrapping key) and derives the inline encryption key from it. +The inline encryption key is the key that actually gets programmed +into a keyslot, and it is never exposed to software. + +However, fscrypt doesn't just do file contents encryption; it also +uses its master keys to derive filenames encryption keys, key +identifiers, and sometimes some more obscure types of subkeys such as +dirhash keys. So even with file contents encryption out of the +picture, fscrypt still needs a raw key to work with. To get such a +key from a hardware-wrapped key, fscrypt asks the inline encryption +hardware to derive a cryptographically isolated "software secret" from +the hardware-wrapped key. fscrypt uses this "software secret" to key +its KDF to derive all subkeys other than file contents keys. + +Note that this implies that the hardware-wrapped key feature only +protects the file contents encryption keys. It doesn't protect other +fscrypt subkeys such as filenames encryption keys. Direct I/O support ==================
fs/crypto/fscrypt_private.h +64 -7
127 lines not on this page · raw message
fs/crypto/hkdf.c +3 -1
@@ -4,7 +4,9 @@* Function"), aka RFC 5869. See also the original paper (Krawczyk 2010): * "Cryptographic Extraction and Key Derivation: The HKDF Scheme". * -* This is used to derive keys from the fscrypt master keys. +* This is used to derive keys from the fscrypt master keys (or from the +* "software secrets" which hardware derives from the fscrypt master keys, in +* the case that the fscrypt master keys are hardware-wrapped keys). * * Copyright 2019 Google LLC */
fs/crypto/inline_crypt.c +39 -7
87 lines not on this page · raw message
fs/crypto/keyring.c +90 -34
201 lines not on this page · raw message
fs/crypto/keysetup.c +51 -3
97 lines not on this page · raw message
fs/crypto/keysetup_v1.c +3 -2
@@ -118,7 +118,8 @@ find_and_lock_process_key(const char *prefix, payload = (const struct fscrypt_key *)ukp->data;if (ukp->datalen !=sizeof (struct fscrypt_key ) || - payload->size <1 || payload->size >FSCRYPT_MAX_KEY_SIZE ) { + payload->size <1 || + payload->size >FSCRYPT_MAX_STANDARD_KEY_SIZE ) {fscrypt_warn (NULL ,"key with description '%s' has invalid payload" , key->description);
@@ -149,7 +150,7 @@ struct fscrypt_direct_key {const struct fscrypt_mode *dk_mode;struct fscrypt_prepared_key dk_key;u8 dk_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE ]; -u8 dk_raw[FSCRYPT_MAX_KEY_SIZE ]; +u8 dk_raw[FSCRYPT_MAX_STANDARD_KEY_SIZE ]; };static void free_direct_key (struct fscrypt_direct_key *dk)
fs/crypto/policy.c +10 -1
@@ -229,7 +229,8 @@ static bool fscrypt_supported_v2_policy(const struct fscrypt_policy_v2 *policy,if (policy->flags & ~(FSCRYPT_POLICY_FLAGS_PAD_MASK |FSCRYPT_POLICY_FLAG_DIRECT_KEY |FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 | -FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 )) { +FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 | +FSCRYPT_POLICY_FLAG_HW_WRAPPED_KEY )) {fscrypt_warn (inode,"Unsupported encryption flags (0x%02x)" , policy->flags);return false;
@@ -269,6 +270,14 @@ static bool fscrypt_supported_v2_policy(const struct fscrypt_policy_v2 *policy, } } +if ((policy->flags &FSCRYPT_POLICY_FLAG_HW_WRAPPED_KEY ) && + !(policy->flags & (FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 | +FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 ))) { +fscrypt_warn (inode, +"HW_WRAPPED_KEY flag can only be used with IV_INO_LBLK_64 or IV_INO_LBLK_32" ); +return false; + } +if ((policy->flags &FSCRYPT_POLICY_FLAG_DIRECT_KEY ) && !supported_direct_key_modes (inode, policy->contents_encryption_mode, policy->filenames_encryption_mode))
include/uapi/linux/fscrypt.h +5 -2
@@ -20,6 +20,7 @@#define FSCRYPT_POLICY_FLAG_DIRECT_KEY 0x04#define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 0x08#define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 0x10 +#define FSCRYPT_POLICY_FLAG_HW_WRAPPED_KEY 0x20/* Encryption algorithms */ #define FSCRYPT_MODE_AES_256_XTS 1
@@ -119,7 +120,7 @@ struct fscrypt_key_specifier {*/ struct fscrypt_provisioning_key_payload {__u32 type; -__u32 __reserved; +__u32 flags;__u8 raw[]; };
@@ -128,7 +129,9 @@ struct fscrypt_add_key_arg {struct fscrypt_key_specifier key_spec;__u32 raw_size;__u32 key_id; -__u32 __reserved[8 ]; +#define FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED 0x00000001 +__u32 flags; +__u32 __reserved[7 ];__u8 raw[]; };
Signature · 1 line
2.45.2
PATCH RESEND v7 5/17 ice, ufs, mmc: use the blk_crypto_key struct when programming the key
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
The program key ops in the storage controller does not pass on the blk_crypto_key structure to ICE, this is okay with raw keys of standard AES XTS sizes. However, wrapped keyblobs can be of any size and in preparation for that, modify the ICE and storage controller APIs to accept blk_crypto_key which can carry larger keys and indicate their size.
--- drivers/mmc/host/cqhci-crypto.c | 7 ++++--- drivers/mmc/host/cqhci.h | 2 ++ drivers/mmc/host/sdhci-msm.c | 6 ++++-- drivers/soc/qcom/ice.c | 6 +++--- drivers/ufs/core/ufshcd-crypto.c | 7 ++++--- drivers/ufs/host/ufs-qcom.c | 6 ++++-- include/soc/qcom/ice.h | 5 +++-- include/ufs/ufshcd.h | 1 + 8 files changed, 25 insertions(+), 15 deletions(-)
drivers/mmc/host/cqhci-crypto.c +4 -3
@@ -32,6 +32,7 @@ cqhci_host_from_crypto_profile(struct blk_crypto_profile *profile) }static int cqhci_crypto_program_key (struct cqhci_host *cq_host, +const struct blk_crypto_key *bkey,const union cqhci_crypto_cfg_entry *cfg,int slot) {
@@ -39,7 +40,7 @@ static int cqhci_crypto_program_key(struct cqhci_host *cq_host,int i;if (cq_host->ops->program_key) -return cq_host->ops->program_key (cq_host, cfg, slot); +return cq_host->ops->program_key (cq_host, bkey, cfg, slot);/* Clear CFGE */ cqhci_writel (cq_host,0 , slot_offset +16 *sizeof (cfg->reg_val[0 ]));
@@ -99,7 +100,7 @@ static int cqhci_crypto_keyslot_program(struct blk_crypto_profile *profile,memcpy (cfg.crypto_key, key->raw, key->size); } - err =cqhci_crypto_program_key (cq_host, &cfg, slot); + err =cqhci_crypto_program_key (cq_host, key, &cfg, slot);memzero_explicit (&cfg,sizeof (cfg));return err;
@@ -113,7 +114,7 @@ static int cqhci_crypto_clear_keyslot(struct cqhci_host *cq_host, int slot)*/ union cqhci_crypto_cfg_entry cfg = {}; -return cqhci_crypto_program_key (cq_host, &cfg, slot); +return cqhci_crypto_program_key (cq_host,NULL , &cfg, slot); } static int cqhci_crypto_keyslot_evict(struct blk_crypto_profile *profile,
drivers/mmc/host/cqhci.h +2 -0
@@ -12,6 +12,7 @@#include <linux/completion.h> #include <linux/wait.h> #include <linux/irqreturn.h> +#include <linux/blk-crypto.h> #include <asm/io.h> /* registers */
@@ -291,6 +292,7 @@ struct cqhci_host_ops {void (*post_disable)(struct mmc_host *mmc);#ifdef CONFIG_MMC_CRYPTO int (*program_key)(struct cqhci_host *cq_host, +const struct blk_crypto_key *bkey,const union cqhci_crypto_cfg_entry *cfg,int slot);#endif void (*set_tran_desc)(struct cqhci_host *cq_host, u8 **desc,
drivers/mmc/host/sdhci-msm.c +4 -2
@@ -1859,6 +1859,7 @@ static __maybe_unused int sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host)* vendor-specific SCM calls for this; it doesn't support the standard way. */ static int sdhci_msm_program_key (struct cqhci_host *cq_host, +const struct blk_crypto_key *bkey,const union cqhci_crypto_cfg_entry *cfg,int slot) {
@@ -1866,6 +1867,7 @@ static int sdhci_msm_program_key(struct cqhci_host *cq_host,struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_msm_host *msm_host =sdhci_pltfm_priv (pltfm_host);union cqhci_crypto_cap_entry cap; +u8 ice_key_size;/* Only AES-256-XTS has been tested so far. */ cap = cq_host->crypto_cap_array[cfg->crypto_cap_idx];
@@ -1873,11 +1875,11 @@ static int sdhci_msm_program_key(struct cqhci_host *cq_host, cap.key_size != CQHCI_CRYPTO_KEY_SIZE_256)return -EINVAL ; + ice_key_size =QCOM_ICE_CRYPTO_KEY_SIZE_256 ;if (cfg->config_enable &CQHCI_CRYPTO_CONFIGURATION_ENABLE )return qcom_ice_program_key (msm_host->ice,QCOM_ICE_CRYPTO_ALG_AES_XTS , -QCOM_ICE_CRYPTO_KEY_SIZE_256 , - cfg->crypto_key, + ice_key_size, bkey, cfg->data_unit_size, slot);else return qcom_ice_evict_key (msm_host->ice, slot);
drivers/soc/qcom/ice.c +3 -3
@@ -163,8 +163,8 @@ EXPORT_SYMBOL_GPL(qcom_ice_suspend);int qcom_ice_program_key (struct qcom_ice *ice,u8 algorithm_id,u8 key_size, -const u8 crypto_key[],u8 data_unit_size, -int slot) +const struct blk_crypto_key *bkey, +u8 data_unit_size,int slot) {struct device *dev = ice->dev;union {
@@ -183,7 +183,7 @@ int qcom_ice_program_key(struct qcom_ice *ice,return -EINVAL ; } -memcpy (key.bytes, crypto_key,AES_256_XTS_KEY_SIZE ); +memcpy (key.bytes, bkey->raw,AES_256_XTS_KEY_SIZE );/* The SCM call requires that the key words are encoded in big endian */ for (i =0 ; i <ARRAY_SIZE (key.words); i++)
drivers/ufs/core/ufshcd-crypto.c +4 -3
@@ -18,6 +18,7 @@ static const struct ufs_crypto_alg_entry { };static int ufshcd_program_key (struct ufs_hba *hba, +const struct blk_crypto_key *bkey,const union ufs_crypto_cfg_entry *cfg,int slot) {int i;
@@ -27,7 +28,7 @@ static int ufshcd_program_key(struct ufs_hba *hba,ufshcd_hold (hba);if (hba->vops && hba->vops->program_key) { - err = hba->vops->program_key (hba, cfg, slot); + err = hba->vops->program_key (hba, bkey, cfg, slot); goto out; }
@@ -89,7 +90,7 @@ static int ufshcd_crypto_keyslot_program(struct blk_crypto_profile *profile,memcpy (cfg.crypto_key, key->raw, key->size); } - err =ufshcd_program_key (hba, &cfg, slot); + err =ufshcd_program_key (hba, key, &cfg, slot);memzero_explicit (&cfg,sizeof (cfg));return err;
@@ -107,7 +108,7 @@ static int ufshcd_crypto_keyslot_evict(struct blk_crypto_profile *profile,*/ union ufs_crypto_cfg_entry cfg = {}; -return ufshcd_program_key (hba, &cfg, slot); +return ufshcd_program_key (hba,NULL , &cfg, slot); }/*
drivers/ufs/host/ufs-qcom.c +4 -2
@@ -150,6 +150,7 @@ static inline int ufs_qcom_ice_suspend(struct ufs_qcom_host *host) }static int ufs_qcom_ice_program_key (struct ufs_hba *hba, +const struct blk_crypto_key *bkey,const union ufs_crypto_cfg_entry *cfg,int slot) {
@@ -157,6 +158,7 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba,union ufs_crypto_cap_entry cap;bool config_enable = cfg->config_enable &UFS_CRYPTO_CONFIGURATION_ENABLE ; +u8 ice_key_size;/* Only AES-256-XTS has been tested so far. */ cap = hba->crypto_cap_array[cfg->crypto_cap_idx];
@@ -164,11 +166,11 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba, cap.key_size != UFS_CRYPTO_KEY_SIZE_256)return -EOPNOTSUPP ; + ice_key_size =QCOM_ICE_CRYPTO_KEY_SIZE_256 ;if (config_enable)return qcom_ice_program_key (host->ice,QCOM_ICE_CRYPTO_ALG_AES_XTS , -QCOM_ICE_CRYPTO_KEY_SIZE_256 , - cfg->crypto_key, + ice_key_size, bkey, cfg->data_unit_size, slot);else return qcom_ice_evict_key (host->ice, slot);
include/soc/qcom/ice.h +3 -2
@@ -7,6 +7,7 @@#define __QCOM_ICE_H__#include <linux/types.h> +#include <linux/blk-crypto.h> struct qcom_ice ;
@@ -30,8 +31,8 @@ int qcom_ice_resume(struct qcom_ice *ice);int qcom_ice_suspend (struct qcom_ice *ice);int qcom_ice_program_key (struct qcom_ice *ice,u8 algorithm_id,u8 key_size, -const u8 crypto_key[],u8 data_unit_size, -int slot); +const struct blk_crypto_key *bkey, +u8 data_unit_size,int slot);int qcom_ice_evict_key (struct qcom_ice *ice,int slot);struct qcom_ice *of_qcom_ice_get (struct device *dev);#endif /* __QCOM_ICE_H__ */
include/ufs/ufshcd.h +1 -0
@@ -373,6 +373,7 @@ struct ufs_hba_variant_ops {struct devfreq_dev_profile *profile, struct devfreq_simple_ondemand_data *data);int (*program_key)(struct ufs_hba *hba, +const struct blk_crypto_key *bkey,const union ufs_crypto_cfg_entry *cfg,int slot); int (*fill_crypto_prdt)(struct ufs_hba *hba, const struct bio_crypt_ctx *crypt_ctx,
Signature · 1 line
2.45.2
Re: [PATCH RESEND v7 05/17] ice, ufs, mmc: use the blk_crypto_key struct when programming the key
Quoted 16 lines · Bartosz Golaszewski
From: Gaurav Kashyap <[email protected]>
The program key ops in the storage controller does not pass on the
blk_crypto_keystructure to ICE, this is okay with raw keys of standard AES XTS sizes. However, wrapped keyblobs can be of any size and in preparation for that, modify the ICE and storage controller APIs to acceptblk_crypto_keywhich can carry larger keys and indicate their size.Reviewed-by Om Prakash Singh <[email protected]>Tested-by Neil Armstrong <[email protected]>Reviewed-by Bartosz Golaszewski <[email protected]>Signed-off-by Gaurav Kashyap <[email protected]>Reviewed-by Konrad Dybcio <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 10 lines
--- drivers/mmc/host/cqhci-crypto.c | 7 ++++--- drivers/mmc/host/cqhci.h | 2 ++ drivers/mmc/host/sdhci-msm.c | 6 ++++-- drivers/soc/qcom/ice.c | 6 +++--- drivers/ufs/core/ufshcd-crypto.c | 7 ++++--- drivers/ufs/host/ufs-qcom.c | 6 ++++-- include/soc/qcom/ice.h | 5 +++-- include/ufs/ufshcd.h | 1 + 8 files changed, 25 insertions(+), 15 deletions(-)
I think this needs to be split on a per-subsystem basis. Otherwise it might be impossible to merge.
Quoted 230 lines
drivers/mmc/host/cqhci-crypto.c +4
-3@@ -32,6 +32,7 @@ cqhci_host_from_crypto_profile(struct blk_crypto_profile *profile) }static int cqhci_crypto_program_key (struct cqhci_host *cq_host, +const struct blk_crypto_key *bkey,const union cqhci_crypto_cfg_entry *cfg,int slot) {@@ -39,7 +40,7 @@ static int cqhci_crypto_program_key(struct cqhci_host *cq_host,int i;if (cq_host->ops->program_key) -return cq_host->ops->program_key (cq_host, cfg, slot); +return cq_host->ops->program_key (cq_host, bkey, cfg, slot);/* Clear CFGE */ cqhci_writel (cq_host,0 , slot_offset +16 *sizeof (cfg->reg_val[0 ]));@@ -99,7 +100,7 @@ static int cqhci_crypto_keyslot_program(struct blk_crypto_profile *profile,memcpy (cfg.crypto_key, key->raw, key->size); } - err =cqhci_crypto_program_key (cq_host, &cfg, slot); + err =cqhci_crypto_program_key (cq_host, key, &cfg, slot);memzero_explicit (&cfg,sizeof (cfg));return err;@@ -113,7 +114,7 @@ static int cqhci_crypto_clear_keyslot(struct cqhci_host *cq_host, int slot)*/ union cqhci_crypto_cfg_entry cfg = {}; -return cqhci_crypto_program_key (cq_host, &cfg, slot); +return cqhci_crypto_program_key (cq_host,NULL , &cfg, slot); } static int cqhci_crypto_keyslot_evict(struct blk_crypto_profile *profile,drivers/mmc/host/cqhci.h +2
-0@@ -12,6 +12,7 @@#include <linux/completion.h> #include <linux/wait.h> #include <linux/irqreturn.h> +#include <linux/blk-crypto.h> #include <asm/io.h> /* registers */ @@ -291,6 +292,7 @@ struct cqhci_host_ops {void (*post_disable)(struct mmc_host *mmc);#ifdef CONFIG_MMC_CRYPTO int (*program_key)(struct cqhci_host *cq_host, +const struct blk_crypto_key *bkey,const union cqhci_crypto_cfg_entry *cfg,int slot);#endif void (*set_tran_desc)(struct cqhci_host *cq_host, u8 **desc,drivers/mmc/host/sdhci-msm.c +4
-2@@ -1859,6 +1859,7 @@ static __maybe_unused int sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host)* vendor-specific SCM calls for this; it doesn't support the standard way. */ static int sdhci_msm_program_key (struct cqhci_host *cq_host, +const struct blk_crypto_key *bkey,const union cqhci_crypto_cfg_entry *cfg,int slot) {@@ -1866,6 +1867,7 @@ static int sdhci_msm_program_key(struct cqhci_host *cq_host,struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_msm_host *msm_host =sdhci_pltfm_priv (pltfm_host);union cqhci_crypto_cap_entry cap; +u8 ice_key_size;/* Only AES-256-XTS has been tested so far. */ cap = cq_host->crypto_cap_array[cfg->crypto_cap_idx];@@ -1873,11 +1875,11 @@ static int sdhci_msm_program_key(struct cqhci_host *cq_host, cap.key_size != CQHCI_CRYPTO_KEY_SIZE_256)return -EINVAL ; + ice_key_size =QCOM_ICE_CRYPTO_KEY_SIZE_256 ;if (cfg->config_enable &CQHCI_CRYPTO_CONFIGURATION_ENABLE )return qcom_ice_program_key (msm_host->ice,QCOM_ICE_CRYPTO_ALG_AES_XTS , -QCOM_ICE_CRYPTO_KEY_SIZE_256 , - cfg->crypto_key, + ice_key_size, bkey, cfg->data_unit_size, slot);else return qcom_ice_evict_key (msm_host->ice, slot);drivers/soc/qcom/ice.c +3
-3@@ -163,8 +163,8 @@ EXPORT_SYMBOL_GPL(qcom_ice_suspend);int qcom_ice_program_key (struct qcom_ice *ice,u8 algorithm_id,u8 key_size, -const u8 crypto_key[],u8 data_unit_size, -int slot) +const struct blk_crypto_key *bkey, +u8 data_unit_size,int slot) {struct device *dev = ice->dev;union {@@ -183,7 +183,7 @@ int qcom_ice_program_key(struct qcom_ice *ice,return -EINVAL ; } -memcpy (key.bytes, crypto_key,AES_256_XTS_KEY_SIZE ); +memcpy (key.bytes, bkey->raw,AES_256_XTS_KEY_SIZE );/* The SCM call requires that the key words are encoded in big endian */ for (i =0 ; i <ARRAY_SIZE (key.words); i++)drivers/ufs/core/ufshcd-crypto.c +4
-3@@ -18,6 +18,7 @@ static const struct ufs_crypto_alg_entry { };static int ufshcd_program_key (struct ufs_hba *hba, +const struct blk_crypto_key *bkey,const union ufs_crypto_cfg_entry *cfg,int slot) {int i;@@ -27,7 +28,7 @@ static int ufshcd_program_key(struct ufs_hba *hba,ufshcd_hold (hba);if (hba->vops && hba->vops->program_key) { - err = hba->vops->program_key (hba, cfg, slot); + err = hba->vops->program_key (hba, bkey, cfg, slot); goto out; }@@ -89,7 +90,7 @@ static int ufshcd_crypto_keyslot_program(struct blk_crypto_profile *profile,memcpy (cfg.crypto_key, key->raw, key->size); } - err =ufshcd_program_key (hba, &cfg, slot); + err =ufshcd_program_key (hba, key, &cfg, slot);memzero_explicit (&cfg,sizeof (cfg));return err;@@ -107,7 +108,7 @@ static int ufshcd_crypto_keyslot_evict(struct blk_crypto_profile *profile,*/ union ufs_crypto_cfg_entry cfg = {}; -return ufshcd_program_key (hba, &cfg, slot); +return ufshcd_program_key (hba,NULL , &cfg, slot); }/* drivers/ufs/host/ufs-qcom.c +4
-2@@ -150,6 +150,7 @@ static inline int ufs_qcom_ice_suspend(struct ufs_qcom_host *host) }static int ufs_qcom_ice_program_key (struct ufs_hba *hba, +const struct blk_crypto_key *bkey,const union ufs_crypto_cfg_entry *cfg,int slot) {@@ -157,6 +158,7 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba,union ufs_crypto_cap_entry cap;bool config_enable = cfg->config_enable &UFS_CRYPTO_CONFIGURATION_ENABLE ; +u8 ice_key_size;/* Only AES-256-XTS has been tested so far. */ cap = hba->crypto_cap_array[cfg->crypto_cap_idx];@@ -164,11 +166,11 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba, cap.key_size != UFS_CRYPTO_KEY_SIZE_256)return -EOPNOTSUPP ; + ice_key_size =QCOM_ICE_CRYPTO_KEY_SIZE_256 ;if (config_enable)return qcom_ice_program_key (host->ice,QCOM_ICE_CRYPTO_ALG_AES_XTS , -QCOM_ICE_CRYPTO_KEY_SIZE_256 , - cfg->crypto_key, + ice_key_size, bkey, cfg->data_unit_size, slot);else return qcom_ice_evict_key (host->ice, slot);include/soc/qcom/ice.h +3
-2@@ -7,6 +7,7 @@#define __QCOM_ICE_H__#include <linux/types.h> +#include <linux/blk-crypto.h> struct qcom_ice ;@@ -30,8 +31,8 @@ int qcom_ice_resume(struct qcom_ice *ice);int qcom_ice_suspend (struct qcom_ice *ice);int qcom_ice_program_key (struct qcom_ice *ice,u8 algorithm_id,u8 key_size, -const u8 crypto_key[],u8 data_unit_size, -int slot); +const struct blk_crypto_key *bkey, +u8 data_unit_size,int slot);int qcom_ice_evict_key (struct qcom_ice *ice,int slot);struct qcom_ice *of_qcom_ice_get (struct device *dev);#endif /* __QCOM_ICE_H__ */ include/ufs/ufshcd.h +1
-0@@ -373,6 +373,7 @@ struct ufs_hba_variant_ops {struct devfreq_dev_profile *profile, struct devfreq_simple_ondemand_data *data);int (*program_key)(struct ufs_hba *hba, +const struct blk_crypto_key *bkey,const union ufs_crypto_cfg_entry *cfg,int slot); int (*fill_crypto_prdt)(struct ufs_hba *hba, const struct bio_crypt_ctx *crypt_ctx,Signature · 2 lines
-- 2.45.2
Signature · 2 lines
With best wishes Dmitry
PATCH RESEND v7 6/17 firmware: qcom: scm: add a call for deriving the software secret
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Inline storage encryption may require deriving a software secret from storage keys added to the kernel.
For raw keys, this can be directly done in the kernel as keys are not encrypted in memory.
However, hardware wrapped keys can only be unwrapped by the HW wrapping entity. In case of Qualcomm's wrapped key solution, this is done by the Hardware Key Manager (HWKM) from Trustzone.
Add a new SCM call which provides a hook to the software secret crypto profile API provided by the block layer.
--- drivers/firmware/qcom/qcom_scm.c | 65 ++++++++++++++++++++++++++++++++++ drivers/firmware/qcom/qcom_scm.h | 1 + include/linux/firmware/qcom/qcom_scm.h | 2 ++ 3 files changed, 68 insertions(+)
drivers/firmware/qcom/qcom_scm.c +65 -0
@@ -1279,6 +1279,71 @@ int qcom_scm_ice_set_key(u32 index, const u8 *key, u32 key_size, }EXPORT_SYMBOL_GPL (qcom_scm_ice_set_key); +/** +* qcom_scm_derive_sw_secret() - Derive software secret from wrapped key +* @wkey: the hardware wrapped key inaccessible to software +* @wkey_size: size of the wrapped key +* @sw_secret: the secret to be derived which is exactly the secret size +* @sw_secret_size: size of the sw_secret +* +* Derive a software secret from a hardware wrapped key for software crypto +* operations. +* For wrapped keys, the key needs to be unwrapped, in order to derive a +* software secret, which can be done in the hardware from a secure execution +* environment. +* +* For more information on sw secret, please refer to "Hardware-wrapped keys" +* section of Documentation/block/inline-encryption.rst. +* +* Return: 0 on success; -errno on failure. +*/ +int qcom_scm_derive_sw_secret (const u8 *wkey,size_t wkey_size, +u8 *sw_secret,size_t sw_secret_size) +{ +struct qcom_scm_desc desc = { + .svc =QCOM_SCM_SVC_ES , + .cmd =QCOM_SCM_ES_DERIVE_SW_SECRET , + .arginfo =QCOM_SCM_ARGS (4 ,QCOM_SCM_RW , +QCOM_SCM_VAL ,QCOM_SCM_RW , +QCOM_SCM_VAL ), + .args[1 ] = wkey_size, + .args[3 ] = sw_secret_size, + .owner =ARM_SMCCC_OWNER_SIP , + }; + +int ret; + + void *wkey_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + wkey_size, +GFP_KERNEL ); +if (!wkey_buf) +return -ENOMEM ; + + void *secret_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + sw_secret_size, +GFP_KERNEL ); +if (!secret_buf) { + ret = -ENOMEM ; + goto out_free_wrapped; + } + +memcpy (wkey_buf, wkey, wkey_size); + desc.args[0 ] =qcom_tzmem_to_phys (wkey_buf); + desc.args[2 ] =qcom_tzmem_to_phys (secret_buf); + + ret =qcom_scm_call (__scm->dev, &desc,NULL ); +if (!ret) +memcpy (sw_secret, secret_buf, sw_secret_size); + +memzero_explicit (secret_buf, sw_secret_size); + +out_free_wrapped: +memzero_explicit (wkey_buf, wkey_size); + +return ret; +} +EXPORT_SYMBOL_GPL (qcom_scm_derive_sw_secret); +/** * qcom_scm_hdcp_available() - Check if secure environment supports HDCP. *
drivers/firmware/qcom/qcom_scm.h +1 -0
@@ -128,6 +128,7 @@ struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void);#define QCOM_SCM_SVC_ES 0x10/* Enterprise Security */ #define QCOM_SCM_ES_INVALIDATE_ICE_KEY 0x03#define QCOM_SCM_ES_CONFIG_SET_ICE_KEY 0x04 +#define QCOM_SCM_ES_DERIVE_SW_SECRET 0x07#define QCOM_SCM_SVC_HDCP 0x11#define QCOM_SCM_HDCP_INVOKE 0x01
include/linux/firmware/qcom/qcom_scm.h +2 -0
@@ -105,6 +105,8 @@ bool qcom_scm_ice_available(void);int qcom_scm_ice_invalidate_key (u32 index);int qcom_scm_ice_set_key (u32 index,const u8 *key,u32 key_size,enum qcom_scm_ice_cipher cipher,u32 data_unit_size); +int qcom_scm_derive_sw_secret (const u8 *wkey,size_t wkey_size, +u8 *sw_secret,size_t sw_secret_size);bool qcom_scm_hdcp_available (void );int qcom_scm_hdcp_req (struct qcom_scm_hdcp_req *req,u32 req_cnt,u32 *resp);
Signature · 1 line
2.45.2
PATCH RESEND v7 7/17 firmware: qcom: scm: add calls for creating, preparing and importing keys
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Storage encryption has two IOCTLs for creating, importing and preparing keys for encryption. For wrapped keys, these IOCTLs need to interface with Qualcomm's Trustzone. Add the following keys:
generate_key:
This is used to generate and return a longterm wrapped key. Trustzone achieves this by generating a key and then wrapping it using the Hawrdware Key Manager (HWKM), returning a wrapped keyblob.
import_key:
The functionality is similar to generate, but here: a raw key is imported into the HWKM and a longterm wrapped keyblob is returned.
prepare_key:
The longterm wrapped key from the import or generate calls is made further secure by rewrapping it with a per-boot, ephemeral wrapped key before installing it in the kernel for programming into ICE.
[Bartosz:
improve kerneldocs,
fix hex values coding style,
rewrite commit message]
--- drivers/firmware/qcom/qcom_scm.c | 161 +++++++++++++++++++++++++++++++++ drivers/firmware/qcom/qcom_scm.h | 3 + include/linux/firmware/qcom/qcom_scm.h | 5 + 3 files changed, 169 insertions(+)
drivers/firmware/qcom/qcom_scm.c +161 -0
@@ -1344,6 +1344,167 @@ int qcom_scm_derive_sw_secret(const u8 *wkey, size_t wkey_size, }EXPORT_SYMBOL_GPL (qcom_scm_derive_sw_secret); +/** +* qcom_scm_generate_ice_key() - Generate a wrapped key for encryption. +* @lt_key: the wrapped key returned after key generation +* @lt_key_size: size of the wrapped key to be returned. +* +* Generate a key using the built-in HW module in the SoC. Wrap the key using +* the platform-specific Key Encryption Key and return to the caller. +* +* Return: 0 on success; -errno on failure. +*/ +int qcom_scm_generate_ice_key (u8 *lt_key,size_t lt_key_size) +{ +struct qcom_scm_desc desc = { + .svc =QCOM_SCM_SVC_ES , + .cmd =QCOM_SCM_ES_GENERATE_ICE_KEY , + .arginfo =QCOM_SCM_ARGS (2 ,QCOM_SCM_RW ,QCOM_SCM_VAL ), + .args[1 ] = lt_key_size, + .owner =ARM_SMCCC_OWNER_SIP , + }; + +int ret; + + void *lt_key_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + lt_key_size, +GFP_KERNEL ); +if (!lt_key_buf) +return -ENOMEM ; + + desc.args[0 ] =qcom_tzmem_to_phys (lt_key_buf); + + ret =qcom_scm_call (__scm->dev, &desc,NULL ); +if (!ret) +memcpy (lt_key, lt_key_buf, lt_key_size); + +memzero_explicit (lt_key_buf, lt_key_size); + +return ret; +} +EXPORT_SYMBOL_GPL (qcom_scm_generate_ice_key); + +/** +* qcom_scm_prepare_ice_key() - Get the per-boot ephemeral wrapped key +* @lt_key: the longterm wrapped key +* @lt_key_size: size of the wrapped key +* @eph_key: ephemeral wrapped key to be returned +* @eph_key_size: size of the ephemeral wrapped key +* +* Qualcomm wrapped keys (longterm keys) are rewrapped with a per-boot +* ephemeral key for added protection. These are ephemeral in nature as +* they are valid only for that boot. +* +* Retrieve the key wrapped with the per-boot ephemeral key and return it to +* the caller. +* +* Return: 0 on success; -errno on failure. +*/ +int qcom_scm_prepare_ice_key (const u8 *lt_key,size_t lt_key_size, +u8 *eph_key,size_t eph_key_size) +{ +struct qcom_scm_desc desc = { + .svc =QCOM_SCM_SVC_ES , + .cmd =QCOM_SCM_ES_PREPARE_ICE_KEY , + .arginfo =QCOM_SCM_ARGS (4 ,QCOM_SCM_RO , +QCOM_SCM_VAL ,QCOM_SCM_RW , +QCOM_SCM_VAL ), + .args[1 ] = lt_key_size, + .args[3 ] = eph_key_size, + .owner =ARM_SMCCC_OWNER_SIP , + }; + +int ret; + + void *lt_key_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + lt_key_size, +GFP_KERNEL ); +if (!lt_key_buf) +return -ENOMEM ; + + void *eph_key_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + eph_key_size, +GFP_KERNEL ); +if (!eph_key_buf) { + ret = -ENOMEM ; + goto out_free_longterm; + } + +memcpy (lt_key_buf, lt_key, lt_key_size); + desc.args[0 ] =qcom_tzmem_to_phys (lt_key_buf); + desc.args[2 ] =qcom_tzmem_to_phys (eph_key_buf); + + ret =qcom_scm_call (__scm->dev, &desc,NULL ); +if (!ret) +memcpy (eph_key, eph_key_buf, eph_key_size); + +memzero_explicit (eph_key_buf, eph_key_size); + +out_free_longterm: +memzero_explicit (lt_key_buf, lt_key_size); + +return ret; +} +EXPORT_SYMBOL_GPL (qcom_scm_prepare_ice_key); + +/** +* qcom_scm_import_ice_key() - Import a wrapped key for encryption +* @imp_key: the raw key that is imported +* @imp_key_size: size of the key to be imported +* @lt_key: the wrapped key to be returned +* @lt_key_size: size of the wrapped key +* +* Import a raw key and return a long-term wrapped key to the caller. +* +* Return: 0 on success; -errno on failure. +*/ +int qcom_scm_import_ice_key (const u8 *imp_key,size_t imp_key_size, +u8 *lt_key,size_t lt_key_size) +{ +struct qcom_scm_desc desc = { + .svc =QCOM_SCM_SVC_ES , + .cmd =QCOM_SCM_ES_IMPORT_ICE_KEY , + .arginfo =QCOM_SCM_ARGS (4 ,QCOM_SCM_RO , +QCOM_SCM_VAL ,QCOM_SCM_RW , +QCOM_SCM_VAL ), + .args[1 ] = imp_key_size, + .args[3 ] = lt_key_size, + .owner =ARM_SMCCC_OWNER_SIP , + }; + +int ret; + + void *imp_key_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + imp_key_size, +GFP_KERNEL ); +if (!imp_key_buf) +return -ENOMEM ; + + void *lt_key_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + lt_key_size, +GFP_KERNEL ); +if (!lt_key_buf) { + ret = -ENOMEM ; + goto out_free_longterm; + } + +memcpy (imp_key_buf, imp_key, imp_key_size); + desc.args[0 ] =qcom_tzmem_to_phys (imp_key_buf); + desc.args[2 ] =qcom_tzmem_to_phys (lt_key_buf); + + ret =qcom_scm_call (__scm->dev, &desc,NULL ); +if (!ret) +memcpy (lt_key, lt_key_buf, lt_key_size); + +memzero_explicit (lt_key_buf, lt_key_size); + +out_free_longterm: +memzero_explicit (imp_key_buf, imp_key_size); + +return ret; +} +EXPORT_SYMBOL_GPL (qcom_scm_import_ice_key); +/** * qcom_scm_hdcp_available() - Check if secure environment supports HDCP. *
drivers/firmware/qcom/qcom_scm.h +3 -0
@@ -129,6 +129,9 @@ struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void);#define QCOM_SCM_ES_INVALIDATE_ICE_KEY 0x03#define QCOM_SCM_ES_CONFIG_SET_ICE_KEY 0x04#define QCOM_SCM_ES_DERIVE_SW_SECRET 0x07 +#define QCOM_SCM_ES_GENERATE_ICE_KEY 0x08 +#define QCOM_SCM_ES_PREPARE_ICE_KEY 0x09 +#define QCOM_SCM_ES_IMPORT_ICE_KEY 0x0a#define QCOM_SCM_SVC_HDCP 0x11#define QCOM_SCM_HDCP_INVOKE 0x01
include/linux/firmware/qcom/qcom_scm.h +5 -0
@@ -107,6 +107,11 @@ int qcom_scm_ice_set_key(u32 index, const u8 *key, u32 key_size, enum qcom_scm_ice_cipher cipher, u32 data_unit_size);int qcom_scm_derive_sw_secret (const u8 *wkey,size_t wkey_size,u8 *sw_secret,size_t sw_secret_size); +int qcom_scm_generate_ice_key (u8 *lt_key,size_t lt_key_size); +int qcom_scm_prepare_ice_key (const u8 *lt_key,size_t lt_key_size, +u8 *eph_key,size_t eph_size); +int qcom_scm_import_ice_key (const u8 *imp_key,size_t imp_size, +u8 *lt_key,size_t lt_key_size);bool qcom_scm_hdcp_available (void );int qcom_scm_hdcp_req (struct qcom_scm_hdcp_req *req,u32 req_cnt,u32 *resp);
Signature · 1 line
2.45.2
PATCH RESEND v7 8/17 firmware: qcom: scm: add a call for checking wrapped key support
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Add a helper that allows users to check if wrapped key support is available on the platform by checking if the SCM call allowing to derive the software secret from a wrapped key is enabled.
--- drivers/firmware/qcom/qcom_scm.c | 7 +++++++ include/linux/firmware/qcom/qcom_scm.h | 1 + 2 files changed, 8 insertions(+)
drivers/firmware/qcom/qcom_scm.c +7 -0
@@ -1279,6 +1279,13 @@ int qcom_scm_ice_set_key(u32 index, const u8 *key, u32 key_size, }EXPORT_SYMBOL_GPL (qcom_scm_ice_set_key); +bool qcom_scm_has_wrapped_key_support (void ) +{ +return __qcom_scm_is_call_available (__scm->dev,QCOM_SCM_SVC_ES , +QCOM_SCM_ES_DERIVE_SW_SECRET ); +} +EXPORT_SYMBOL_GPL (qcom_scm_has_wrapped_key_support); +/** * qcom_scm_derive_sw_secret() - Derive software secret from wrapped key * @wkey: the hardware wrapped key inaccessible to software
include/linux/firmware/qcom/qcom_scm.h +1 -0
@@ -112,6 +112,7 @@ int qcom_scm_prepare_ice_key(const u8 *lt_key, size_t lt_key_size, u8 *eph_key, size_t eph_size);int qcom_scm_import_ice_key (const u8 *imp_key,size_t imp_size,u8 *lt_key,size_t lt_key_size); +bool qcom_scm_has_wrapped_key_support (void );bool qcom_scm_hdcp_available (void );int qcom_scm_hdcp_req (struct qcom_scm_hdcp_req *req,u32 req_cnt,u32 *resp);
Signature · 1 line
2.45.2
PATCH RESEND v7 9/17 soc: qcom: ice: add HWKM support to the ICE driver
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Qualcomm's ICE (Inline Crypto Engine) contains a proprietary key management hardware called Hardware Key Manager (HWKM). Add HWKM support to the ICE driver if it is available on the platform. HWKM primarily provides hardware wrapped key support where the ICE (storage) keys are not available in software and instead protected in hardware.
When HWKM software support is not fully available (from Trustzone), there can be a scenario where the ICE hardware supports HWKM, but it cannot be used for wrapped keys. In this case, raw keys have to be used without using the HWKM. We query the TZ at run-time to find out whether wrapped keys support is available.
--- drivers/soc/qcom/ice.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++-- include/soc/qcom/ice.h | 1 + 2 files changed, 149 insertions(+), 4 deletions(-)
drivers/soc/qcom/ice.c +148 -4
@@ -27,6 +27,40 @@#define QCOM_ICE_REG_FUSE_SETTING 0x0010#define QCOM_ICE_REG_BIST_STATUS 0x0070#define QCOM_ICE_REG_ADVANCED_CONTROL 0x1000 +#define QCOM_ICE_REG_CONTROL 0x0 +/* QCOM ICE HWKM registers */ +#define QCOM_ICE_REG_HWKM_TZ_KM_CTL 0x1000 +#define QCOM_ICE_REG_HWKM_TZ_KM_STATUS 0x1004 +#define QCOM_ICE_REG_HWKM_BANK0_BANKN_IRQ_STATUS 0x2008 +#define QCOM_ICE_REG_HWKM_BANK0_BBAC_0 0x5000 +#define QCOM_ICE_REG_HWKM_BANK0_BBAC_1 0x5004 +#define QCOM_ICE_REG_HWKM_BANK0_BBAC_2 0x5008 +#define QCOM_ICE_REG_HWKM_BANK0_BBAC_3 0x500C +#define QCOM_ICE_REG_HWKM_BANK0_BBAC_4 0x5010 + +/* QCOM ICE HWKM reg vals */ +#define QCOM_ICE_HWKM_BIST_DONE_V1 BIT(16) +#define QCOM_ICE_HWKM_BIST_DONE_V2 BIT(9) +#define QCOM_ICE_HWKM_BIST_DONE (ver) QCOM_ICE_HWKM_BIST_DONE_V##ver + +#define QCOM_ICE_HWKM_CRYPTO_BIST_DONE_V1 BIT(14) +#define QCOM_ICE_HWKM_CRYPTO_BIST_DONE_V2 BIT(7) +#define QCOM_ICE_HWKM_CRYPTO_BIST_DONE (v) QCOM_ICE_HWKM_CRYPTO_BIST_DONE_V##v + +#define QCOM_ICE_HWKM_BOOT_CMD_LIST1_DONE BIT(2) +#define QCOM_ICE_HWKM_BOOT_CMD_LIST0_DONE BIT(1) +#define QCOM_ICE_HWKM_KT_CLEAR_DONE BIT(0) + +#define QCOM_ICE_HWKM_BIST_VAL (v) (QCOM_ICE_HWKM_BIST_DONE(v) | \ + QCOM_ICE_HWKM_CRYPTO_BIST_DONE(v) | \ + QCOM_ICE_HWKM_BOOT_CMD_LIST1_DONE | \ + QCOM_ICE_HWKM_BOOT_CMD_LIST0_DONE | \ + QCOM_ICE_HWKM_KT_CLEAR_DONE) + +#define QCOM_ICE_HWKM_V1_STANDARD_MODE_VAL (BIT(0) | BIT(1) | BIT(2)) +#define QCOM_ICE_HWKM_V2_STANDARD_MODE_MASK GENMASK(31, 1) +#define QCOM_ICE_HWKM_DISABLE_CRC_CHECKS_VAL (BIT(1) | BIT(2)) +#define QCOM_ICE_HWKM_RSP_FIFO_CLEAR_VAL BIT(3)/* BIST ("built-in self-test") status flags */ #define QCOM_ICE_BIST_STATUS_MASK GENMASK(31, 28)
@@ -35,6 +69,9 @@#define QCOM_ICE_FORCE_HW_KEY0_SETTING_MASK 0x2#define QCOM_ICE_FORCE_HW_KEY1_SETTING_MASK 0x4 +#define QCOM_ICE_HWKM_REG_OFFSET 0x8000 +#define HWKM_OFFSET (reg) ((reg) + QCOM_ICE_HWKM_REG_OFFSET) +#define qcom_ice_writel (engine, val, reg) \ writel((val), (engine)->base + (reg))
@@ -46,6 +83,9 @@ struct qcom_ice {void __iomem *base;struct clk *core_clk; +u8 hwkm_version; +bool use_hwkm; +bool hwkm_init_complete; };static bool qcom_ice_check_supported (struct qcom_ice *ice)
@@ -63,8 +103,21 @@ static bool qcom_ice_check_supported(struct qcom_ice *ice)return false; } -dev_info (dev,"Found QC Inline Crypto Engine (ICE) v%d.%d.%d\n" , - major, minor, step); +if (major >=4 || (major ==3 && minor ==2 && step >=1 )) + ice->hwkm_version =2 ; +else if (major ==3 && minor ==2 ) + ice->hwkm_version =1 ; +else + ice->hwkm_version =0 ; + +if (ice->hwkm_version ==0 ) + ice->use_hwkm = false; + +dev_info (dev,"Found QC Inline Crypto Engine (ICE) v%d.%d.%d, HWKM v%d\n" , + major, minor, step, ice->hwkm_version); + +if (!ice->use_hwkm) +dev_info (dev,"QC ICE HWKM (Hardware Key Manager) not used/supported" );/* If fuses are blown, ICE might not work in the standard way. */ regval =qcom_ice_readl (ice,QCOM_ICE_REG_FUSE_SETTING );
@@ -113,27 +166,106 @@ static void qcom_ice_optimization_enable(struct qcom_ice *ice)* fails, so we needn't do it in software too, and (c) properly testing * storage encryption requires testing the full storage stack anyway, * and not relying on hardware-level self-tests. +* +* However, we still care about if HWKM BIST failed (when supported) as +* important functionality would fail later, so disable hwkm on failure. */ static int qcom_ice_wait_bist_status (struct qcom_ice *ice) {u32 regval; +u32 bist_done_val;int err; err =readl_poll_timeout (ice->base +QCOM_ICE_REG_BIST_STATUS , regval, !(regval &QCOM_ICE_BIST_STATUS_MASK ),50 ,5000 ); -if (err) +if (err) {dev_err (ice->dev,"Timed out waiting for ICE self-test to complete\n" ); +return err; + } +if (ice->use_hwkm) { + bist_done_val = ice->hwkm_version ==1 ? +QCOM_ICE_HWKM_BIST_VAL (1 ) : +QCOM_ICE_HWKM_BIST_VAL (2 ); +if (qcom_ice_readl (ice, +HWKM_OFFSET (QCOM_ICE_REG_HWKM_TZ_KM_STATUS )) != + bist_done_val) { +dev_err (ice->dev,"HWKM BIST error\n" ); + ice->use_hwkm = false; + err = -ENODEV ; + } + }return err; } +static void qcom_ice_enable_standard_mode (struct qcom_ice *ice) +{ +u32 val =0 ; + +/* +* When ICE is in standard (hwkm) mode, it supports HW wrapped +* keys, and when it is in legacy mode, it only supports standard +* (non HW wrapped) keys. +* +* Put ICE in standard mode, ICE defaults to legacy mode. +* Legacy mode - ICE HWKM slave not supported. +* Standard mode - ICE HWKM slave supported. +* +* Depending on the version of HWKM, it is controlled by different +* registers in ICE. +*/ +if (ice->hwkm_version >=2 ) { + val =qcom_ice_readl (ice,QCOM_ICE_REG_CONTROL ); + val = val &QCOM_ICE_HWKM_V2_STANDARD_MODE_MASK ; +qcom_ice_writel (ice, val,QCOM_ICE_REG_CONTROL ); + }else { +qcom_ice_writel (ice,QCOM_ICE_HWKM_V1_STANDARD_MODE_VAL , +HWKM_OFFSET (QCOM_ICE_REG_HWKM_TZ_KM_CTL )); + } +} + +static void qcom_ice_hwkm_init (struct qcom_ice *ice) +{ +/* Disable CRC checks. This HWKM feature is not used. */ +qcom_ice_writel (ice,QCOM_ICE_HWKM_DISABLE_CRC_CHECKS_VAL , +HWKM_OFFSET (QCOM_ICE_REG_HWKM_TZ_KM_CTL )); + +/* +* Give register bank of the HWKM slave access to read and modify +* the keyslots in ICE HWKM slave. Without this, trustzone will not +* be able to program keys into ICE. +*/ +qcom_ice_writel (ice,GENMASK (31 ,0 ),HWKM_OFFSET (QCOM_ICE_REG_HWKM_BANK0_BBAC_0 )); +qcom_ice_writel (ice,GENMASK (31 ,0 ),HWKM_OFFSET (QCOM_ICE_REG_HWKM_BANK0_BBAC_1 )); +qcom_ice_writel (ice,GENMASK (31 ,0 ),HWKM_OFFSET (QCOM_ICE_REG_HWKM_BANK0_BBAC_2 )); +qcom_ice_writel (ice,GENMASK (31 ,0 ),HWKM_OFFSET (QCOM_ICE_REG_HWKM_BANK0_BBAC_3 )); +qcom_ice_writel (ice,GENMASK (31 ,0 ),HWKM_OFFSET (QCOM_ICE_REG_HWKM_BANK0_BBAC_4 )); + +/* Clear HWKM response FIFO before doing anything */ +qcom_ice_writel (ice,QCOM_ICE_HWKM_RSP_FIFO_CLEAR_VAL , +HWKM_OFFSET (QCOM_ICE_REG_HWKM_BANK0_BANKN_IRQ_STATUS )); + ice->hwkm_init_complete = true; +} +int qcom_ice_enable (struct qcom_ice *ice) { +int err; +qcom_ice_low_power_mode_enable (ice);qcom_ice_optimization_enable (ice); -return qcom_ice_wait_bist_status (ice); +if (ice->use_hwkm) +qcom_ice_enable_standard_mode (ice); + + err =qcom_ice_wait_bist_status (ice); +if (err) +return err; + +if (ice->use_hwkm) +qcom_ice_hwkm_init (ice); + +return err; }EXPORT_SYMBOL_GPL (qcom_ice_enable);
@@ -149,6 +281,10 @@ int qcom_ice_resume(struct qcom_ice *ice)return err; } +if (ice->use_hwkm) { +qcom_ice_enable_standard_mode (ice); +qcom_ice_hwkm_init (ice); + }return qcom_ice_wait_bist_status (ice); }EXPORT_SYMBOL_GPL (qcom_ice_resume);
@@ -156,6 +292,7 @@ EXPORT_SYMBOL_GPL(qcom_ice_resume);int qcom_ice_suspend (struct qcom_ice *ice) {clk_disable_unprepare (ice->core_clk); + ice->hwkm_init_complete = false;return 0 ; }
@@ -205,6 +342,12 @@ int qcom_ice_evict_key(struct qcom_ice *ice, int slot) }EXPORT_SYMBOL_GPL (qcom_ice_evict_key); +bool qcom_ice_hwkm_supported (struct qcom_ice *ice) +{ +return ice->use_hwkm; +} +EXPORT_SYMBOL_GPL (qcom_ice_hwkm_supported); +static struct qcom_ice *qcom_ice_create (struct device *dev,void __iomem *base) {
@@ -239,6 +382,7 @@ static struct qcom_ice *qcom_ice_create(struct device *dev, engine->core_clk =devm_clk_get_enabled (dev,NULL );if (IS_ERR (engine->core_clk))return ERR_CAST (engine->core_clk); + engine->use_hwkm =qcom_scm_has_wrapped_key_support ();if (!qcom_ice_check_supported (engine))return ERR_PTR (-EOPNOTSUPP );
include/soc/qcom/ice.h +1 -0
@@ -34,5 +34,6 @@ int qcom_ice_program_key(struct qcom_ice *ice,const struct blk_crypto_key *bkey, u8 data_unit_size, int slot);int qcom_ice_evict_key (struct qcom_ice *ice,int slot); +bool qcom_ice_hwkm_supported (struct qcom_ice *ice);struct qcom_ice *of_qcom_ice_get (struct device *dev);#endif /* __QCOM_ICE_H__ */
Signature · 1 line
2.45.2
PATCH RESEND v7 10/17 soc: qcom: ice: add support for hardware wrapped keys
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Now that HWKM support has been added to ICE, extend the ICE driver to support hardware wrapped keys programming coming in from the storage controllers (UFS and eMMC). This is similar to raw keys where the call is forwarded to Trustzone, however we also need to clear and re-enable CFGE before and after programming the key.
Derive software secret support is also added by forwarding the call to the corresponding SCM API.
Wrapped keys are only used if the new module parameter is set AND the architecture supports HWKM.
--- drivers/soc/qcom/ice.c | 128 ++++++++++++++++++++++++++++++++++++++++++++----- include/soc/qcom/ice.h | 4 ++ 2 files changed, 121 insertions(+), 11 deletions(-)
drivers/soc/qcom/ice.c +117 -11
@@ -28,6 +28,8 @@#define QCOM_ICE_REG_BIST_STATUS 0x0070#define QCOM_ICE_REG_ADVANCED_CONTROL 0x1000#define QCOM_ICE_REG_CONTROL 0x0 +#define QCOM_ICE_LUT_KEYS_CRYPTOCFG_R16 0x4040 +/* QCOM ICE HWKM registers */ #define QCOM_ICE_REG_HWKM_TZ_KM_CTL 0x1000#define QCOM_ICE_REG_HWKM_TZ_KM_STATUS 0x1004
@@ -62,6 +64,8 @@#define QCOM_ICE_HWKM_DISABLE_CRC_CHECKS_VAL (BIT(1) | BIT(2))#define QCOM_ICE_HWKM_RSP_FIFO_CLEAR_VAL BIT(3) +#define QCOM_ICE_HWKM_CFG_ENABLE_VAL BIT(7) +/* BIST ("built-in self-test") status flags */ #define QCOM_ICE_BIST_STATUS_MASK GENMASK(31, 28)
@@ -69,6 +73,8 @@#define QCOM_ICE_FORCE_HW_KEY0_SETTING_MASK 0x2#define QCOM_ICE_FORCE_HW_KEY1_SETTING_MASK 0x4 +#define QCOM_ICE_LUT_KEYS_CRYPTOCFG_OFFSET 0x80 +#define QCOM_ICE_HWKM_REG_OFFSET 0x8000#define HWKM_OFFSET (reg) ((reg) + QCOM_ICE_HWKM_REG_OFFSET)
@@ -78,6 +84,15 @@#define qcom_ice_readl (engine, reg) \ readl((engine)->base + (reg)) +#define QCOM_ICE_LUT_CRYPTOCFG_SLOT_OFFSET (slot) \ + (QCOM_ICE_LUT_KEYS_CRYPTOCFG_R16 + \ + QCOM_ICE_LUT_KEYS_CRYPTOCFG_OFFSET * slot) + +static bool ufs_qcom_use_wrapped_keys; +module_param_named (use_wrapped_keys, ufs_qcom_use_wrapped_keys, bool,0660 ); +MODULE_PARM_DESC (use_wrapped_keys, +"Use HWKM for wrapped keys support if available on the platform" ); +struct qcom_ice {struct device *dev;void __iomem *base;
@@ -88,6 +103,16 @@ struct qcom_ice {bool hwkm_init_complete; }; +union crypto_cfg { +__le32 regval; +struct { +u8 dusize; +u8 capidx; +u8 reserved; +u8 cfge; + }; +}; +static bool qcom_ice_check_supported (struct qcom_ice *ice) {u32 regval =qcom_ice_readl (ice,QCOM_ICE_REG_VERSION );
@@ -298,6 +323,46 @@ int qcom_ice_suspend(struct qcom_ice *ice) }EXPORT_SYMBOL_GPL (qcom_ice_suspend); +/* +* For v1 the ICE slot will be calculated in the trustzone. +*/ +static int translate_hwkm_slot (struct qcom_ice *ice,int slot) +{ +return (ice->hwkm_version ==1 ) ? slot : (slot *2 ); +} + +static int qcom_ice_program_wrapped_key (struct qcom_ice *ice, +const struct blk_crypto_key *key, +u8 data_unit_size,int slot) +{ +union crypto_cfg cfg = { + .dusize = data_unit_size, + .capidx =QCOM_SCM_ICE_CIPHER_AES_256_XTS , + .cfge =QCOM_ICE_HWKM_CFG_ENABLE_VAL , + }; +int hwkm_slot; +int err; + + hwkm_slot =translate_hwkm_slot (ice, slot); + +/* Clear CFGE */ +qcom_ice_writel (ice,0x0 ,QCOM_ICE_LUT_CRYPTOCFG_SLOT_OFFSET (slot)); + +/* Call trustzone to program the wrapped key using hwkm */ + err =qcom_scm_ice_set_key (hwkm_slot, key->raw, key->size, +QCOM_SCM_ICE_CIPHER_AES_256_XTS , data_unit_size); +if (err) { +pr_err ("%s:SCM call Error: 0x%x slot %d\n" , __func__, err, + slot); +return err; + } + +/* Enable CFGE after programming key */ +qcom_ice_writel (ice, cfg.regval,QCOM_ICE_LUT_CRYPTOCFG_SLOT_OFFSET (slot)); + +return err; +} + int qcom_ice_program_key(struct qcom_ice *ice, u8 algorithm_id, u8 key_size, const struct blk_crypto_key *bkey,
@@ -313,24 +378,40 @@ int qcom_ice_program_key(struct qcom_ice *ice,/* Only AES-256-XTS has been tested so far. */ if (algorithm_id !=QCOM_ICE_CRYPTO_ALG_AES_XTS || - key_size !=QCOM_ICE_CRYPTO_KEY_SIZE_256 ) { + (key_size !=QCOM_ICE_CRYPTO_KEY_SIZE_256 && + key_size !=QCOM_ICE_CRYPTO_KEY_SIZE_WRAPPED )) {dev_err_ratelimited (dev,"Unhandled crypto capability; algorithm_id=%d, key_size=%d\n" , algorithm_id, key_size);return -EINVAL ; } -memcpy (key.bytes, bkey->raw,AES_256_XTS_KEY_SIZE ); +if (ufs_qcom_use_wrapped_keys && + (bkey->crypto_cfg.key_type ==BLK_CRYPTO_KEY_TYPE_HW_WRAPPED )) { +/* It is expected that HWKM init has completed before programming wrapped keys */ +if (!ice->use_hwkm || !ice->hwkm_init_complete) { +dev_err_ratelimited (dev,"HWKM not currently used or initialized\n" ); +return -EINVAL ; + } + err =qcom_ice_program_wrapped_key (ice, bkey, data_unit_size, + slot); + }else { +if (bkey->size !=QCOM_ICE_CRYPTO_KEY_SIZE_256 ) +dev_err_ratelimited (dev, +"Incorrect key size; bkey->size=%d\n" , + algorithm_id); +return -EINVAL ; +memcpy (key.bytes, bkey->raw,AES_256_XTS_KEY_SIZE ); -/* The SCM call requires that the key words are encoded in big endian */ -for (i =0 ; i <ARRAY_SIZE (key.words); i++) -__cpu_to_be32s (&key.words[i]); +/* The SCM call requires that the key words are encoded in big endian */ +for (i =0 ; i <ARRAY_SIZE (key.words); i++) +__cpu_to_be32s (&key.words[i]); - err =qcom_scm_ice_set_key (slot, key.bytes,AES_256_XTS_KEY_SIZE , -QCOM_SCM_ICE_CIPHER_AES_256_XTS , - data_unit_size); - -memzero_explicit (&key,sizeof (key)); + err =qcom_scm_ice_set_key (slot, key.bytes,AES_256_XTS_KEY_SIZE , +QCOM_SCM_ICE_CIPHER_AES_256_XTS , + data_unit_size); +memzero_explicit (&key,sizeof (key)); + }return err; }
@@ -338,7 +419,23 @@ EXPORT_SYMBOL_GPL(qcom_ice_program_key);int qcom_ice_evict_key (struct qcom_ice *ice,int slot) { -return qcom_scm_ice_invalidate_key (slot); +int hwkm_slot = slot; + +if (ice->use_hwkm) { + hwkm_slot =translate_hwkm_slot (ice, slot); + +/* +* Ignore calls to evict key when HWKM is supported and hwkm +* init is not yet done. This is to avoid the clearing all +* slots call during a storage reset when ICE is still in +* legacy mode. HWKM slave in ICE takes care of zeroing out +* the keytable on reset. +*/ +if (!ice->hwkm_init_complete) +return 0 ; + } + +return qcom_scm_ice_invalidate_key (hwkm_slot); }EXPORT_SYMBOL_GPL (qcom_ice_evict_key);
@@ -348,6 +445,15 @@ bool qcom_ice_hwkm_supported(struct qcom_ice *ice) }EXPORT_SYMBOL_GPL (qcom_ice_hwkm_supported); +int qcom_ice_derive_sw_secret (struct qcom_ice *ice,const u8 wkey[], +unsigned int wkey_size, +u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE ]) +{ +return qcom_scm_derive_sw_secret (wkey, wkey_size, + sw_secret,BLK_CRYPTO_SW_SECRET_SIZE ); +} +EXPORT_SYMBOL_GPL (qcom_ice_derive_sw_secret); +static struct qcom_ice *qcom_ice_create (struct device *dev,void __iomem *base) {
include/soc/qcom/ice.h +4 -0
@@ -17,6 +17,7 @@ enum qcom_ice_crypto_key_size {QCOM_ICE_CRYPTO_KEY_SIZE_192 =0x2 ,QCOM_ICE_CRYPTO_KEY_SIZE_256 =0x3 ,QCOM_ICE_CRYPTO_KEY_SIZE_512 =0x4 , + QCOM_ICE_CRYPTO_KEY_SIZE_WRAPPED = 0x5, }; enum qcom_ice_crypto_alg {
@@ -35,5 +36,8 @@ int qcom_ice_program_key(struct qcom_ice *ice, u8 data_unit_size, int slot);int qcom_ice_evict_key (struct qcom_ice *ice,int slot);bool qcom_ice_hwkm_supported (struct qcom_ice *ice); +int qcom_ice_derive_sw_secret (struct qcom_ice *ice,const u8 wkey[], +unsigned int wkey_size, +u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE ]);struct qcom_ice *of_qcom_ice_get (struct device *dev);#endif /* __QCOM_ICE_H__ */
Signature · 1 line
2.45.2
Re: [PATCH RESEND v7 10/17] soc: qcom: ice: add support for hardware wrapped keys
Quoted 56 lines · Bartosz Golaszewski
From: Gaurav Kashyap <[email protected]>
Now that HWKM support has been added to ICE, extend the ICE driver to support hardware wrapped keys programming coming in from the storage controllers (UFS and eMMC). This is similar to raw keys where the call is forwarded to Trustzone, however we also need to clear and re-enable CFGE before and after programming the key.
Derive software secret support is also added by forwarding the call to the corresponding SCM API.
Wrapped keys are only used if the new module parameter is set AND the architecture supports HWKM.
Tested-by Neil Armstrong <[email protected]>Reviewed-by Om Prakash Singh <[email protected]>Signed-off-by Gaurav Kashyap <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/soc/qcom/ice.c | 128 ++++++++++++++++++++++++++++++++++++++++++++----- include/soc/qcom/ice.h | 4 ++ 2 files changed, 121 insertions(+), 11 deletions(-)drivers/soc/qcom/ice.c +6
-0@@ -28,6 +28,8 @@#define QCOM_ICE_REG_BIST_STATUS 0x0070#define QCOM_ICE_REG_ADVANCED_CONTROL 0x1000#define QCOM_ICE_REG_CONTROL 0x0 +#define QCOM_ICE_LUT_KEYS_CRYPTOCFG_R16 0x4040 +/* QCOM ICE HWKM registers */ #define QCOM_ICE_REG_HWKM_TZ_KM_CTL 0x1000#define QCOM_ICE_REG_HWKM_TZ_KM_STATUS 0x1004@@ -62,6 +64,8 @@#define QCOM_ICE_HWKM_DISABLE_CRC_CHECKS_VAL (BIT(1) | BIT(2))#define QCOM_ICE_HWKM_RSP_FIFO_CLEAR_VAL BIT(3) +#define QCOM_ICE_HWKM_CFG_ENABLE_VAL BIT(7) +/* BIST ("built-in self-test") status flags */ #define QCOM_ICE_BIST_STATUS_MASK GENMASK(31, 28)@@ -69,6 +73,8 @@#define QCOM_ICE_FORCE_HW_KEY0_SETTING_MASK 0x2#define QCOM_ICE_FORCE_HW_KEY1_SETTING_MASK 0x4 +#define QCOM_ICE_LUT_KEYS_CRYPTOCFG_OFFSET 0x80 +#define QCOM_ICE_HWKM_REG_OFFSET 0x8000#define HWKM_OFFSET (reg) ((reg) + QCOM_ICE_HWKM_REG_OFFSET)@@ -78,6 +84,15 @@#define qcom_ice_readl (engine, reg) \
drivers/soc/qcom/ice.c line 94
Quoted 10 lines
drivers/soc/qcom/ice.c +8
-0readl((engine)->base + (reg)) +#define QCOM_ICE_LUT_CRYPTOCFG_SLOT_OFFSET (slot) \ + (QCOM_ICE_LUT_KEYS_CRYPTOCFG_R16 + \ + QCOM_ICE_LUT_KEYS_CRYPTOCFG_OFFSET * slot) + +static bool ufs_qcom_use_wrapped_keys; +module_param_named (use_wrapped_keys, ufs_qcom_use_wrapped_keys, bool,0660 ); +MODULE_PARM_DESC (use_wrapped_keys, +"Use HWKM for wrapped keys support if available on the platform" );
This should go into the previous patch and it should be handled in qcom_ice_check_supported() instead.
Quoted 4 lines
drivers/soc/qcom/ice.c +1
-0+struct qcom_ice {struct device *dev;void __iomem *base;
[...]
Quoted 5 lines
drivers/soc/qcom/ice.c +0
-1@@ -313,24 +378,40 @@ int qcom_ice_program_key(struct qcom_ice *ice,/* Only AES-256-XTS has been tested so far. */ if (algorithm_id != QCOM_ICE_CRYPTO_ALG_AES_XTS || - key_size !=QCOM_ICE_CRYPTO_KEY_SIZE_256 ) {
drivers/soc/qcom/ice.c int qcom_ice_program_key(struct qcom_ice *ice, · line 389
Quoted 10 lines
drivers/soc/qcom/ice.c +3
-1+ (key_size != QCOM_ICE_CRYPTO_KEY_SIZE_256 && + key_size != QCOM_ICE_CRYPTO_KEY_SIZE_WRAPPED)) {dev_err_ratelimited (dev,"Unhandled crypto capability; algorithm_id=%d, key_size=%d\n" , algorithm_id, key_size);return -EINVAL ; } -memcpy (key.bytes, bkey->raw,AES_256_XTS_KEY_SIZE ); + if (ufs_qcom_use_wrapped_keys &&
I think it's too late to have the check here.
Quoted 36 lines
drivers/soc/qcom/ice.c +23
-8+ (bkey->crypto_cfg.key_type == BLK_CRYPTO_KEY_TYPE_HW_WRAPPED)) { +/* It is expected that HWKM init has completed before programming wrapped keys */ +if (!ice->use_hwkm || !ice->hwkm_init_complete) { +dev_err_ratelimited (dev,"HWKM not currently used or initialized\n" ); +return -EINVAL ; + } + err =qcom_ice_program_wrapped_key (ice, bkey, data_unit_size, + slot); + } else { +if (bkey->size !=QCOM_ICE_CRYPTO_KEY_SIZE_256 ) +dev_err_ratelimited (dev, +"Incorrect key size; bkey->size=%d\n" , + algorithm_id); +return -EINVAL ; +memcpy (key.bytes, bkey->raw,AES_256_XTS_KEY_SIZE ); -/* The SCM call requires that the key words are encoded in big endian */ -for (i =0 ; i <ARRAY_SIZE (key.words); i++) -__cpu_to_be32s (&key.words[i]); +/* The SCM call requires that the key words are encoded in big endian */ +for (i =0 ; i <ARRAY_SIZE (key.words); i++) +__cpu_to_be32s (&key.words[i]); - err =qcom_scm_ice_set_key (slot, key.bytes,AES_256_XTS_KEY_SIZE , -QCOM_SCM_ICE_CIPHER_AES_256_XTS , - data_unit_size); - -memzero_explicit (&key,sizeof (key)); + err =qcom_scm_ice_set_key (slot, key.bytes,AES_256_XTS_KEY_SIZE , +QCOM_SCM_ICE_CIPHER_AES_256_XTS , + data_unit_size); +memzero_explicit (&key,sizeof (key)); + }return err; }
Signature · 2 lines
With best wishes Dmitry
PATCH RESEND v7 11/17 soc: qcom: ice: add support for generating, importing and preparing keys
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
With the new SCM calls that interface with TrustZone and allow us to use the Hardware Key Manager functionality, we can now add support for hardware wrapped keys to the Qualcomm ICE SoC driver.
Upcoming patches will connect that layer with the block layer ioctls.
--- drivers/soc/qcom/ice.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/soc/qcom/ice.h | 8 +++++ 2 files changed, 89 insertions(+)
drivers/soc/qcom/ice.c +81 -0
@@ -22,6 +22,13 @@#define AES_256_XTS_KEY_SIZE 64 +/* +* Wrapped key sizes that HWKM expects and manages is different for different +* versions of the hardware. +*/ +#define QCOM_ICE_HWKM_WRAPPED_KEY_SIZE (v) \ + ((v) == 1 ? 68 : 100) +/* QCOM ICE registers */ #define QCOM_ICE_REG_VERSION 0x0008#define QCOM_ICE_REG_FUSE_SETTING 0x0010
@@ -454,6 +461,80 @@ int qcom_ice_derive_sw_secret(struct qcom_ice *ice, const u8 wkey[], }EXPORT_SYMBOL_GPL (qcom_ice_derive_sw_secret); +/** +* qcom_ice_generate_key() - Generate a wrapped key for inline encryption +* @ice: ICE driver data +* @lt_key: long-term wrapped key to be generated, which is +* BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE in size. +* +* Make a scm call into trustzone to generate a wrapped key for storage +* encryption using hwkm. +* +* Returns: 0 on success, -errno on failure. +*/ +int qcom_ice_generate_key (struct qcom_ice *ice, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +size_t wk_size =QCOM_ICE_HWKM_WRAPPED_KEY_SIZE (ice->hwkm_version); + +if (!qcom_scm_generate_ice_key (lt_key, wk_size)) +return wk_size; + +return 0 ; +} +EXPORT_SYMBOL_GPL (qcom_ice_generate_key); + +/** +* qcom_ice_prepare_key() - Prepare a long-term wrapped key for inline encryption +* @ice: ICE driver data +* @lt_key: longterm wrapped key that was generated or imported. +* @lt_key_size: size of the longterm wrapped_key +* @eph_key: wrapped key returned which has been wrapped with a per-boot ephemeral key, +* size of which is BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE in size. +* +* Make a scm call into trustzone to prepare a wrapped key for storage +* encryption by rewrapping the longterm wrapped key with a per boot ephemeral +* key using hwkm. +* +* Return: 0 on success; -errno on failure. +*/ +int qcom_ice_prepare_key (struct qcom_ice *ice,const u8 *lt_key,size_t lt_key_size, +u8 eph_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +size_t wk_size =QCOM_ICE_HWKM_WRAPPED_KEY_SIZE (ice->hwkm_version); + +if (!qcom_scm_prepare_ice_key (lt_key, lt_key_size, eph_key, wk_size)) +return wk_size; + +return 0 ; +} +EXPORT_SYMBOL_GPL (qcom_ice_prepare_key); + +/** +* qcom_ice_import_key() - Import a raw key for inline encryption +* ice: ICE driver data +* @imp_key: raw key that has to be imported +* @imp_key_size: size of the imported key +* @lt_key: longterm wrapped key that is imported, which is +* BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE in size. +* +* Make a scm call into trustzone to import a raw key for storage encryption +* and generate a longterm wrapped key using hwkm. +* +* Return: 0 on success; -errno on failure. +*/ +int qcom_ice_import_key (struct qcom_ice *ice,const u8 *imp_key,size_t imp_key_size, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +size_t wk_size =QCOM_ICE_HWKM_WRAPPED_KEY_SIZE (ice->hwkm_version); + +if (!qcom_scm_import_ice_key (imp_key, imp_key_size, lt_key, wk_size)) +return wk_size; + +return 0 ; +} +EXPORT_SYMBOL_GPL (qcom_ice_import_key); +static struct qcom_ice *qcom_ice_create (struct device *dev,void __iomem *base) {
include/soc/qcom/ice.h +8 -0
@@ -39,5 +39,13 @@ bool qcom_ice_hwkm_supported(struct qcom_ice *ice);int qcom_ice_derive_sw_secret (struct qcom_ice *ice,const u8 wkey[],unsigned int wkey_size,u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE ]); +int qcom_ice_generate_key (struct qcom_ice *ice, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]); +int qcom_ice_prepare_key (struct qcom_ice *ice, +const u8 *lt_key,size_t lt_key_size, +u8 eph_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]); +int qcom_ice_import_key (struct qcom_ice *ice, +const u8 *imp_key,size_t imp_key_size, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]);struct qcom_ice *of_qcom_ice_get (struct device *dev);#endif /* __QCOM_ICE_H__ */
Signature · 1 line
2.45.2
kernel test robot
build botRe: [PATCH RESEND v7 11/17] soc: qcom: ice: add support for generating, importing and preparing keys
kernel test robot noticed the following build warnings:
Hi Bartosz,
kernel test robot noticed the following build warnings:
[auto build test WARNING on f486c8aa16b8172f63bddc70116a0c897a7f3f02]
url: https://github.com/intel-lab-lkp/linux/commits/Bartosz-Golaszewski/blk-crypto-add-basic-hardware-wrapped-key-support/20241202-201228 base: f486c8aa16b8172f63bddc70116a0c897a7f3f02 patch link: https://lore.kernel.org/r/20241202-wrapped-keys-v7-11-67c3ca3f3282%40linaro.org patch subject: [PATCH RESEND v7 11/17] soc: qcom: ice: add support for generating, importing and preparing keys config: i386-buildonly-randconfig-006-20241203 (https://download.01.org/0day-ci/archive/20241203/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241203/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/soc/qcom/ice.c:528: warning: Function parameter or struct member 'ice' not described in 'qcom_ice_import_key'
vim +528 drivers/soc/qcom/ice.c
512
513 /**
514 * qcom_ice_import_key() - Import a raw key for inline encryption
515 * ice: ICE driver data
516 * @imp_key: raw key that has to be imported
517 * @imp_key_size: size of the imported key
518 * @lt_key: longterm wrapped key that is imported, which is
519 * BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE in size.
520 *
521 * Make a scm call into trustzone to import a raw key for storage encryption
522 * and generate a longterm wrapped key using hwkm.
523 *
524 * Return: 0 on success; -errno on failure.
525 */
526 int qcom_ice_import_key(struct qcom_ice *ice, const u8 *imp_key, size_t imp_key_size,
527 u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE])
> 528 { 529 size_t wk_size = QCOM_ICE_HWKM_WRAPPED_KEY_SIZE(ice->hwkm_version);
530
531 if (!qcom_scm_import_ice_key(imp_key, imp_key_size, lt_key, wk_size))
532 return wk_size;
533
534 return 0;
535 }
536 EXPORT_SYMBOL_GPL(qcom_ice_import_key);
537
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH RESEND v7 12/17 ufs: core: add support for wrapped keys to UFS core
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Add a new UFS capability flag indicating that the controller supports HW wrapped keys and use it to determine which mechanism to use in UFS core.
--- drivers/ufs/core/ufshcd-crypto.c | 24 ++++++++++++++++-------- include/ufs/ufshcd.h | 5 +++++ 2 files changed, 21 insertions(+), 8 deletions(-)
drivers/ufs/core/ufshcd-crypto.c +16 -8
@@ -81,13 +81,15 @@ static int ufshcd_crypto_keyslot_program(struct blk_crypto_profile *profile, cfg.crypto_cap_idx = cap_idx; cfg.config_enable =UFS_CRYPTO_CONFIGURATION_ENABLE ; -if (ccap_array[cap_idx].algorithm_id ==UFS_CRYPTO_ALG_AES_XTS ) { -/* In XTS mode, the blk_crypto_key's size is already doubled */ -memcpy (cfg.crypto_key, key->raw, key->size/2 ); -memcpy (cfg.crypto_key +UFS_CRYPTO_KEY_MAX_SIZE /2 , - key->raw + key->size/2 , key->size/2 ); - }else { -memcpy (cfg.crypto_key, key->raw, key->size); +if (key->crypto_cfg.key_type !=BLK_CRYPTO_KEY_TYPE_HW_WRAPPED ) { +if (ccap_array[cap_idx].algorithm_id ==UFS_CRYPTO_ALG_AES_XTS ) { +/* In XTS mode, the blk_crypto_key's size is already doubled */ +memcpy (cfg.crypto_key, key->raw, key->size /2 ); +memcpy (cfg.crypto_key +UFS_CRYPTO_KEY_MAX_SIZE /2 , + key->raw + key->size /2 , key->size /2 ); + }else { +memcpy (cfg.crypto_key, key->raw, key->size); + } } err =ufshcd_program_key (hba, key, &cfg, slot);
@@ -196,7 +198,13 @@ int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba) hba->crypto_profile.ll_ops = ufshcd_crypto_ops;/* UFS only supports 8 bytes for any DUN */ hba->crypto_profile.max_dun_bytes_supported =8 ; - hba->crypto_profile.key_types_supported =BLK_CRYPTO_KEY_TYPE_STANDARD ; +if (hba->caps &UFSHCD_CAP_WRAPPED_CRYPTO_KEYS ) + hba->crypto_profile.key_types_supported = +BLK_CRYPTO_KEY_TYPE_HW_WRAPPED ; +else + hba->crypto_profile.key_types_supported = +BLK_CRYPTO_KEY_TYPE_STANDARD ; + hba->crypto_profile.dev = hba->dev;/*
include/ufs/ufshcd.h +5 -0
@@ -761,6 +761,11 @@ enum ufshcd_caps {* WriteBooster when scaling the clock down. */ UFSHCD_CAP_WB_WITH_CLK_SCALING =1 <<12 , + +/* +* UFS controller supports HW wrapped keys when using inline encryption. +*/ + UFSHCD_CAP_WRAPPED_CRYPTO_KEYS = 1 << 13, }; struct ufs_hba_variant_params {
Signature · 1 line
2.45.2
PATCH RESEND v7 13/17 ufs: core: add support for deriving the software secret
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Extend the UFS core to allow calling the block layer's callback for deriving the software secret from a wrapped key. This is needed as in most cases the wrapped key support will be vendor-specific and the implementation will live in the specific UFS driver.
--- drivers/ufs/core/ufshcd-crypto.c | 15 +++++++++++++++ include/ufs/ufshcd.h | 3 +++ 2 files changed, 18 insertions(+)
drivers/ufs/core/ufshcd-crypto.c +15 -0
@@ -113,6 +113,20 @@ static int ufshcd_crypto_keyslot_evict(struct blk_crypto_profile *profile,return ufshcd_program_key (hba,NULL , &cfg, slot); } +static int ufshcd_crypto_derive_sw_secret (struct blk_crypto_profile *profile, +const u8 wkey[],size_t wkey_size, +u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE ]) +{ +struct ufs_hba *hba = + container_of(profile, struct ufs_hba, crypto_profile); + +if (hba->vops && hba->vops->derive_sw_secret) +return hba->vops->derive_sw_secret (hba, wkey, wkey_size, + sw_secret); + +return -EOPNOTSUPP ; +} +/* * Reprogram the keyslots if needed, and return true if CRYPTO_GENERAL_ENABLE * should be used in the host controller initialization sequence.
@@ -134,6 +148,7 @@ bool ufshcd_crypto_enable(struct ufs_hba *hba)static const struct blk_crypto_ll_ops ufshcd_crypto_ops = { .keyslot_program = ufshcd_crypto_keyslot_program, .keyslot_evict = ufshcd_crypto_keyslot_evict, + .derive_sw_secret = ufshcd_crypto_derive_sw_secret, }; static enum blk_crypto_mode_num
include/ufs/ufshcd.h +3 -0
@@ -375,6 +375,9 @@ struct ufs_hba_variant_ops {int (*program_key)(struct ufs_hba *hba,const struct blk_crypto_key *bkey,const union ufs_crypto_cfg_entry *cfg,int slot); +int (*derive_sw_secret)(struct ufs_hba *hba,const u8 wkey[], +unsigned int wkey_size, +u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE ]);int (*fill_crypto_prdt)(struct ufs_hba *hba,const struct bio_crypt_ctx *crypt_ctx,void *prdt,unsigned int num_segments);
Signature · 1 line
2.45.2
PATCH RESEND v7 14/17 ufs: core: add support for generating, importing and preparing keys
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
The block layer now allows storage controllers to implement the operations for handling wrapped keys. We can now extend the UFS core to also support them by reaching into the block layer. Add hooks corresponding with the existing crypto operations lower on the stack.
--- drivers/ufs/core/ufshcd-crypto.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/ufs/core/ufshcd-crypto.c +41 -0
@@ -145,10 +145,51 @@ bool ufshcd_crypto_enable(struct ufs_hba *hba)return true; } +static int ufshcd_crypto_generate_key (struct blk_crypto_profile *profile, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +struct ufs_hba *hba = + container_of(profile, struct ufs_hba, crypto_profile); + +if (hba->vops && hba->vops->generate_key) +return hba->vops->generate_key (hba, lt_key); + +return -EOPNOTSUPP ; +} + +static int ufshcd_crypto_prepare_key (struct blk_crypto_profile *profile, +const u8 *lt_key,size_t lt_key_size, +u8 eph_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +struct ufs_hba *hba = + container_of(profile, struct ufs_hba, crypto_profile); + +if (hba->vops && hba->vops->prepare_key) +return hba->vops->prepare_key (hba, lt_key, lt_key_size, eph_key); + +return -EOPNOTSUPP ; +} + +static int ufshcd_crypto_import_key (struct blk_crypto_profile *profile, +const u8 *imp_key,size_t imp_key_size, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +struct ufs_hba *hba = + container_of(profile, struct ufs_hba, crypto_profile); + +if (hba->vops && hba->vops->import_key) +return hba->vops->import_key (hba, imp_key, imp_key_size, lt_key); + +return -EOPNOTSUPP ; +} +static const struct blk_crypto_ll_ops ufshcd_crypto_ops = { .keyslot_program = ufshcd_crypto_keyslot_program, .keyslot_evict = ufshcd_crypto_keyslot_evict, .derive_sw_secret = ufshcd_crypto_derive_sw_secret, + .generate_key = ufshcd_crypto_generate_key, + .prepare_key = ufshcd_crypto_prepare_key, + .import_key = ufshcd_crypto_import_key, }; static enum blk_crypto_mode_num
Signature · 1 line
2.45.2
PATCH RESEND v7 15/17 ufs: host: add support for wrapped keys in QCom UFS
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Use the wrapped keys capability when HWKM is supported. Whether to use HWKM or not would be decided during an ICE probe, and based on this information, UFS can decide to use wrapped or raw keys.
Also, propagate the appropriate key size to the ICE driver when wrapped keys are used.
--- drivers/ufs/host/ufs-qcom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/ufs/host/ufs-qcom.c +7 -1
@@ -129,6 +129,8 @@ static int ufs_qcom_ice_init(struct ufs_qcom_host *host) host->ice = ice; hba->caps |=UFSHCD_CAP_CRYPTO ; +if (qcom_ice_hwkm_supported (host->ice)) + hba->caps |=UFSHCD_CAP_WRAPPED_CRYPTO_KEYS ;return 0 ; }
@@ -166,7 +168,11 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba, cap.key_size != UFS_CRYPTO_KEY_SIZE_256)return -EOPNOTSUPP ; - ice_key_size =QCOM_ICE_CRYPTO_KEY_SIZE_256 ; +if (bkey->crypto_cfg.key_type ==BLK_CRYPTO_KEY_TYPE_HW_WRAPPED ) + ice_key_size =QCOM_ICE_CRYPTO_KEY_SIZE_WRAPPED ; +else + ice_key_size =QCOM_ICE_CRYPTO_KEY_SIZE_256 ; +if (config_enable) return qcom_ice_program_key(host->ice, QCOM_ICE_CRYPTO_ALG_AES_XTS,
Signature · 1 line
2.45.2
PATCH RESEND v7 16/17 ufs: host: add a callback for deriving software secrets and use it
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Add a new UFS core callback for deriving software secrets from hardware wrapped keys and implement it in QCom UFS.
--- drivers/ufs/host/ufs-qcom.c | 15 +++++++++++++++ include/ufs/ufshcd.h | 1 + 2 files changed, 16 insertions(+)
drivers/ufs/host/ufs-qcom.c +15 -0
@@ -182,9 +182,23 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba, return qcom_ice_evict_key(host->ice, slot); } +/* +* Derive a software secret from a hardware wrapped key. The key is unwrapped in +* hardware from trustzone and a software key/secret is then derived from it. +*/ +static int ufs_qcom_ice_derive_sw_secret (struct ufs_hba *hba,const u8 wkey[], +unsigned int wkey_size, +u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE ]) +{ +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + +return qcom_ice_derive_sw_secret (host->ice, wkey, wkey_size, sw_secret); +} +#else #define ufs_qcom_ice_program_key NULL +#define ufs_qcom_ice_derive_sw_secret NULLstatic inline void ufs_qcom_ice_enable (struct ufs_qcom_host *host) {
@@ -1833,6 +1847,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .device_reset = ufs_qcom_device_reset, .config_scaling_param = ufs_qcom_config_scaling_param, .program_key = ufs_qcom_ice_program_key, + .derive_sw_secret = ufs_qcom_ice_derive_sw_secret, .reinit_notify = ufs_qcom_reinit_notify, .mcq_config_resource = ufs_qcom_mcq_config_resource, .get_hba_mac = ufs_qcom_get_hba_mac,
include/ufs/ufshcd.h +1 -0
@@ -325,6 +325,7 @@ struct ufs_pwr_mode_info {* @device_reset: called to issue a reset pulse on the UFS device * @config_scaling_param: called to configure clock scaling parameters * @program_key: program or evict an inline encryption key +* @derive_sw_secret: derive sw secret from a wrapped key * @fill_crypto_prdt: initialize crypto-related fields in the PRDT * @event_notify: called to notify important events * @reinit_notify: called to notify reinit of UFSHCD during max gear switch
Signature · 1 line
2.45.2
PATCH RESEND v7 17/17 ufs: host: add support for generating, importing and preparing wrapped keys
In reply to Bartosz GolaszewskiFrom: Gaurav Kashyap <[email protected]>
Extend the UFS core ops to include callbacks for generating, importing and prepating HW wrapped keys using the lower-level block crypto operations and implement them for QCom UFS.
--- drivers/ufs/host/ufs-qcom.c | 34 ++++++++++++++++++++++++++++++++++ include/ufs/ufshcd.h | 11 +++++++++++ 2 files changed, 45 insertions(+)
drivers/ufs/host/ufs-qcom.c +34 -0
@@ -195,10 +195,41 @@ static int ufs_qcom_ice_derive_sw_secret(struct ufs_hba *hba, const u8 wkey[],return qcom_ice_derive_sw_secret (host->ice, wkey, wkey_size, sw_secret); } +static int ufs_qcom_ice_generate_key (struct ufs_hba *hba, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + +return qcom_ice_generate_key (host->ice, lt_key); +} + +static int ufs_qcom_ice_prepare_key (struct ufs_hba *hba, +const u8 *lt_key,size_t lt_key_size, +u8 eph_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + +return qcom_ice_prepare_key (host->ice, lt_key, lt_key_size, + eph_key); +} + +static int ufs_qcom_ice_import_key (struct ufs_hba *hba, +const u8 *imp_key,size_t imp_key_size, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]) +{ +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + +return qcom_ice_import_key (host->ice, imp_key, imp_key_size, + lt_key); +} +#else #define ufs_qcom_ice_program_key NULL#define ufs_qcom_ice_derive_sw_secret NULL +#define ufs_qcom_ice_generate_key NULL +#define ufs_qcom_ice_prepare_key NULL +#define ufs_qcom_ice_import_key NULLstatic inline void ufs_qcom_ice_enable (struct ufs_qcom_host *host) {
@@ -1848,6 +1879,9 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .config_scaling_param = ufs_qcom_config_scaling_param, .program_key = ufs_qcom_ice_program_key, .derive_sw_secret = ufs_qcom_ice_derive_sw_secret, + .generate_key = ufs_qcom_ice_generate_key, + .prepare_key = ufs_qcom_ice_prepare_key, + .import_key = ufs_qcom_ice_import_key, .reinit_notify = ufs_qcom_reinit_notify, .mcq_config_resource = ufs_qcom_mcq_config_resource, .get_hba_mac = ufs_qcom_get_hba_mac,
include/ufs/ufshcd.h +11 -0
@@ -326,6 +326,9 @@ struct ufs_pwr_mode_info {* @config_scaling_param: called to configure clock scaling parameters * @program_key: program or evict an inline encryption key * @derive_sw_secret: derive sw secret from a wrapped key +* @generate_key: generate a storage key and return longterm wrapped key +* @prepare_key: unwrap longterm key and return ephemeral wrapped key +* @import_key: import sw storage key and return longterm wrapped key * @fill_crypto_prdt: initialize crypto-related fields in the PRDT * @event_notify: called to notify important events * @reinit_notify: called to notify reinit of UFSHCD during max gear switch
@@ -379,6 +382,14 @@ struct ufs_hba_variant_ops {int (*derive_sw_secret)(struct ufs_hba *hba,const u8 wkey[],unsigned int wkey_size,u8 sw_secret[BLK_CRYPTO_SW_SECRET_SIZE ]); +int (*generate_key)(struct ufs_hba *hba, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]); +int (*prepare_key)(struct ufs_hba *hba, +const u8 *lt_key,size_t lt_key_size, +u8 eph_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]); +int (*import_key)(struct ufs_hba *hba, +const u8 *imp_key,size_t imp_key_size, +u8 lt_key[BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE ]);int (*fill_crypto_prdt)(struct ufs_hba *hba,const struct bio_crypt_ctx *crypt_ctx,void *prdt,unsigned int num_segments);
Signature · 1 line
2.45.2
Eric Biggers
maintainerQuoted 4 lines · Bartosz Golaszewski
The previous iteration[1] has been on the list for many weeks without receiving any comments - neither positive nor negative. If there are no objections - could we start discussing how to make these patches go upstream for v6.14?
The way to do it will be for the block patches to be taken through the block tree first. That will unblock the rest, which can be taken through their respective trees in subsequent cycles.
I'm really hoping to be able to test these patches with upstream myself, which I'm not able to do yet. I'll try to leave some review comments on the parts not authored by me the mean time. Anyway, thanks for continuing to work on this.
Quoted 24 lines
Tested on sm8650-qrd.
How to test:
Use the wip-wrapped-keys branch from https://github.com/ebiggers/fscryptctl
to build a custom fscryptctl that supports generating wrapped keys.Enable the following config options:
CONFIG_BLK_INLINE_ENCRYPTION=yCONFIG_QCOM_INLINE_CRYPTO_ENGINE=mCONFIG_FS_ENCRYPTION_INLINE_CRYPT=yCONFIG_SCSI_UFS_CRYPTO=y$ mkfs.ext4 -F -O encrypt,stable_inodes /dev/disk/by-partlabel/userdata $ mount /dev/disk/by-partlabel/userdata -o inlinecrypt /mnt $ fscryptctl generate_hw_wrapped_key /dev/disk/by-partlabel/userdata > /mnt/key.longterm $ fscryptctl prepare_hw_wrapped_key /dev/disk/by-partlabel/userdata < /mnt/key.longterm > /tmp/key.ephemeral $ KEYID=$(fscryptctl add_key --hw-wrapped-key < /tmp/key.ephemeral /mnt) $ rm -rf /mnt/dir $ mkdir /mnt/dir $ fscryptctl set_policy --hw-wrapped-key --iv-ino-lblk-64 "$KEYID" /mnt/dir $ dmesg > /mnt/dir/test.txt $ sync
Quoted 8 lines
Reboot the board
$ mount /dev/disk/by-partlabel/userdata -o inlinecrypt /mnt $ ls /mnt/dir $ fscryptctl prepare_hw_wrapped_key /dev/disk/by-partlabel/userdata < /mnt/key.longterm > /tmp/key.ephemeral $ KEYID=$(fscryptctl add_key --hw-wrapped-key < /tmp/key.ephemeral /mnt) $ fscryptctl set_policy --hw-wrapped-key --iv-ino-lblk-64 "$KEYID" /mnt/dir $ cat /mnt/dir/test.txt # File should now be decrypted
That doesn't verify that the encryption is being done correctly, which is the most important thing to test. For that we'll need to resurrect the following patchset for xfstests:
https://lore.kernel.org/fstests/[email protected]/
- Eric
Jens Axboe
maintainerQuoted 9 lines · Eric Biggers
Quoted 4 lines · Bartosz Golaszewski
The previous iteration[1] has been on the list for many weeks without receiving any comments - neither positive nor negative. If there are no objections - could we start discussing how to make these patches go upstream for v6.14?
The way to do it will be for the block patches to be taken through the block tree first. That will unblock the rest, which can be taken through their respective trees in subsequent cycles.
I can queue up patches 1..3 in a separate branch that we can both use, and that can get pulled into for-6.14/block as well. Didn't want to do that before the rest of them are ready. IOW, if it's going to be bound for 6.14, let me know, and I'll setup the branch with the patches.
Signature · 1 line
Jens Axboe