Skip to content

Commit 246e6f8

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 89463da commit 246e6f8

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
@@ -315,6 +315,16 @@ config DM_CRYPT
315315

316316
If unsure, say N.
317317

318+
config DM_INLINECRYPT
319+
tristate "Inline encryption target support"
320+
depends on BLK_DEV_DM
321+
depends on BLK_INLINE_ENCRYPTION
322+
help
323+
This device-mapper target is similar to dm-crypt, but it uses the
324+
blk-crypto API instead of the regular crypto API. This allows it to
325+
take advantage of inline encryption hardware such as that commonly
326+
built into UFS host controllers.
327+
318328
config DM_SNAPSHOT
319329
tristate "Snapshot target"
320330
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)