aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/md/dm-inlinecrypt.c
AgeCommit message (Collapse)AuthorFilesLines
13 daysMerge tag 'for-7.3/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dmLinus Torvalds1-1/+0
Pull device mapper updates from Mikulas Patocka: - minor cleanups found by Claude Opus 4.6 - small cleanups in dm core, dm-cache, dm-switch, dm-inlinecrypt, dm-vdo - improve validation of metadata in dm-pcache - fix resume-vs-remove ioctl race condition - fix race condition when issuing table load ioctls concurrently - fix dm-raid1 and dm-io, so that they work with unaligned bio vectors - dm-integrity: use keyed markers as discard fillers - improve metadata validation in dm-array - fix dm-stats crash on memory allocation failure - fix dm-dust, so that it works if it is not the first target in a table - dm-era: fix superblock refcount leak on snapshot failure * tag 'for-7.3/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: (46 commits) dm-era: fix shadowed superblock leak on take-snap failure dm dust: make badblock messages target-relative dm-stats: fix a crash if allocation of per-cpu data fails dm array: reject an array block whose value size is not the caller's dm array: validate array block headers on read dm-integrity: replace forgeable discard filler with a keyed sector marker dm vdo indexer: embed geometry in parent structures dm vdo indexer: simplify sub-index parameter calculations dm-pcache: remove unused 'cache' parameter from cache_key_gc() docs: device-mapper: dm-inlinecrypt: fix 'bellow' spelling dm-pcache: remove unused miss_read_end_work_fn declaration dm-io: report non-retryable errors separatedly dm-io: clone the source bio instead of copying its biovec dm: fix race when loading and unloading a table dm: fix resume-vs-remove race dm-pcache: remove unused 'allocated' variable in cache_data_alloc() dm-pcache: replace tabs with spaces in comments to fix ASCII diagram alignment dm-pcache: fix use-after-free and invalid seg operations in kset_replay() dm-pcache: fix implicit u8 truncation of gc_percent in message handler dm raid1: reserve space for NUL-terminator in build_constructor_string() ...
2026-07-20blk-crypto: Allow control over whether hardware is usedEric Biggers1-1/+2
fscrypt uses inline encryption hardware only when the "inlinecrypt" mount option is given. I'd like to keep that behavior even after standardizing on the blk-crypto API for file contents encryption. That is, the default should continue to be the well-tested CPU-based encryption code, and the use of inline encryption hardware should continue to be an opt-in feature for systems where it's beneficial and has been fully validated (including verifying ciphertext correctness). To support this use case, extend blk_crypto_config with a new flag BLK_CRYPTO_CFG_ALLOW_HW. For now it's always set. Later commits will change that. Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260713023708.9245-4-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
2026-07-16dm-inlinecrypt: don't overwrite the error with -EINVALMikulas Patocka1-1/+0
get_key_size already returns -EINVAL on error, so we don't have to overwrite it again. No functional change. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-07-08dm-inlinecrypt: Fix an error handling path in inlinecrypt_ctr()Christophe JAILLET1-1/+3
All error handling paths, except but this one, branch to the 'bad' label in the error handling path. If not done, there is a memory leak and some sensitive data may be kept around. So, fix this error path and also do the needed clean-up. Also, fix missing goto in the "Wrong alignment of iv_offset sector" path. Fixes: e7f57d2c47e2 ("dm-inlinecrypt: add target for inline block device encryption") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-05-25dm-inlinecrypt: add support for hardware-wrapped keysLinlin Zhang1-22/+41
Add support for hardware-wrapped encryption keys to the dm-inlinecrypt target. Introduce a new optional argument <key_type> to indicate whether the provided key is a raw key or a hardware-wrapped key. Based on this flag, the appropriate blk-crypto key type is selected when initializing the key. This allows dm-inlinecrypt to work with hardware that requires keys to be wrapped and managed by the underlying inline encryption engine. Update the target argument parsing accordingly and pass the key type to blk_crypto_init_key(). Documentation is also updated to reflect the new parameter and usage. Signed-off-by: Linlin Zhang <linlin.zhang@oss.qualcomm.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Fixes: e7f57d2c47e2 ("dm-inlinecrypt: add target for inline block device encryption")
2026-05-12dm-inlinecrypt: add target for inline block device encryptionEric Biggers1-0/+599
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>