Skip to content

Commit 5a4339f

Browse files
ebiggerskawasaki
authored andcommitted
dm-inlinecrypt: add target for inline block device encryption
Add a new device-mapper target "dm-inlinecrypt" that is similar to dm-crypt but uses the blk-crypto API instead of the regular crypto API. This allows it to take advantage of inline encryption hardware such as that commonly built into UFS host controllers. The table syntax matches dm-crypt's, but for now only a stripped-down set of parameters is supported. For example, for now AES-256-XTS is the only supported cipher. dm-inlinecrypt is based on Android's dm-default-key with the controversial passthrough support removed. Note that due to the removal of passthrough support, use of dm-inlinecrypt in combination with fscrypt causes double encryption of file contents (similar to dm-crypt + fscrypt), with the fscrypt layer not being able to use the inline encryption hardware. This makes dm-inlinecrypt unusable on systems such as Android that use fscrypt and where a more optimized approach is needed. It is however suitable as a replacement for dm-crypt. dm-inlinecrypt supports both keyring key and hex key, the former avoids the key to be exposed in dm-table message. Similar to dm-default-key in Android, it will fallabck to the software block crypto once the inline crypto hardware cannot support the expected cipher. Test: dmsetup create inlinecrypt_logon --table "0 `blockdev --getsz $1` \ inlinecrypt aes-xts-plain64 :64:logon:fde:dminlinecrypt_test_key 0 $1 0" Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Linlin Zhang <[email protected]>
1 parent 9b0071c commit 5a4339f

3 files changed

Lines changed: 570 additions & 0 deletions

File tree

drivers/md/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ config DM_CRYPT
313313

314314
If unsure, say N.
315315

316+
config DM_INLINECRYPT
317+
tristate "Inline encryption target support"
318+
depends on BLK_DEV_DM
319+
depends on BLK_INLINE_ENCRYPTION
320+
help
321+
This device-mapper target is similar to dm-crypt, but it uses the
322+
blk-crypto API instead of the regular crypto API. This allows it to
323+
take advantage of inline encryption hardware such as that commonly
324+
built into UFS host controllers.
325+
316326
config DM_SNAPSHOT
317327
tristate "Snapshot target"
318328
depends on BLK_DEV_DM

drivers/md/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ obj-$(CONFIG_DM_UNSTRIPED) += dm-unstripe.o
5555
obj-$(CONFIG_DM_BUFIO) += dm-bufio.o
5656
obj-$(CONFIG_DM_BIO_PRISON) += dm-bio-prison.o
5757
obj-$(CONFIG_DM_CRYPT) += dm-crypt.o
58+
obj-$(CONFIG_DM_INLINECRYPT) += dm-inlinecrypt.o
5859
obj-$(CONFIG_DM_DELAY) += dm-delay.o
5960
obj-$(CONFIG_DM_DUST) += dm-dust.o
6061
obj-$(CONFIG_DM_FLAKEY) += dm-flakey.o

0 commit comments

Comments
 (0)