History

fscrypt: add support for hardware-wrapped keys

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. 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. The version of this feature introduced by this patch is mostly equivalent to the version that has existed downstream in the Android Common Kernels since 2020. However, a couple fixes are included. First, the flags field in struct fscrypt_add_key_arg is now placed in the proper location. Second, key identifiers for HW-wrapped keys are now derived using a distinct HKDF context byte; this fixes a bug where a raw key could have the same identifier as a HW-wrapped key. Note that as a result of these fixes, the version of this feature introduced by this patch is not UAPI or on-disk format compatible with the version in the Android Common Kernels, though the divergence is limited to just those specific fixes. This version should be used going forwards. This patch has been heavily rewritten from the original version by Gaurav Kashyap <quic_gaurkash@quicinc.com> and Barani Muthukumaran <bmuthuku@codeaurora.org>.

Eric Biggers committed 1 year ago

Commit c07d3ae1 parent 0af2f6b8 files · +410 −105Browse files

Showing the changes to include/uapi/linux (1 of 8 files). Show all

Unified · Split

include/uapi/linux/fscrypt.h+4−2
@@ -119,7 +119,7 @@ struct fscrypt_key_specifier { · 118 unmodified lines
119 */119 */
120struct fscrypt_provisioning_key_payload {120struct fscrypt_provisioning_key_payload {
121 __u32 type;121 __u32 type;
122 __u32 __reserved;122 __u32 flags;
123 __u8 raw[];123 __u8 raw[];
124};124};
125 125
@@ -128,7 +128,9 @@ struct fscrypt_add_key_arg { · 2 unmodified lines
128 struct fscrypt_key_specifier key_spec;128 struct fscrypt_key_specifier key_spec;
129 __u32 raw_size;129 __u32 raw_size;
130 __u32 key_id;130 __u32 key_id;
131 __u32 __reserved[8];131#define FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED 0x00000001
132 __u32 flags;
133 __u32 __reserved[7];
132 __u8 raw[];134 __u8 raw[];
133};135};
134 136