Skip to content

Commit e7f57d2

Browse files
ebiggersMikulas Patocka
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 <ebiggers@google.com> Signed-off-by: Linlin Zhang <linlin.zhang@oss.qualcomm.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
1 parent 623463c commit e7f57d2

3 files changed

Lines changed: 611 additions & 0 deletions

File tree

drivers/md/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ 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 (KEYS || KEYS=n)
322+
depends on BLK_INLINE_ENCRYPTION
323+
help
324+
This device-mapper target is similar to dm-crypt, but it uses the
325+
blk-crypto API instead of the regular crypto API. This allows it to
326+
take advantage of inline encryption hardware such as that commonly
327+
built into UFS host controllers.
328+
318329
config DM_SNAPSHOT
319330
tristate "Snapshot target"
320331
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)