dm-default-key: target for filesystem metadata encryption
Subsystems (5)
Eric Biggers
maintainercover dm-default-key: target for filesystem metadata encryption
This series adds "metadata encryption" support to ext4 and f2fs via a new device-mapper target dm-default-key. dm-default-key encrypts all data on a block device that isn't already encrypted by the filesystem.
Except for the passthrough support, dm-default-key is basically the same as the proposed dm-inlinecrypt which omits that feature
(https://lore.kernel.org/dm-devel/[email protected]/).
I am sending this out for reference, as dm-default-key (which Android has been using for a while) hasn't previously been sent to the lists in full, and there has been interest in it. However, my current impression is that this feature will need to be redesigned as a filesystem native feature in order to make it upstream. If that is indeed the case, then IMO it would make sense to merge dm-inlinecrypt in the mean time instead (or add its functionality to dm-crypt) so that anyone who just wants "dm-crypt + inline encryption hardware" gets a solution for that.
Eric Biggers (4):
block: export blk-crypto symbols required by dm-default-key
block: add the bi_skip_dm_default_key flag
dm-default-key: add target for filesystem metadata encryption ext4,f2fs: support metadata encryption via dm-default-key
block/bio.c | 3 + block/blk-crypto-fallback.c | 2 + block/blk-crypto.c | 3 + drivers/md/Kconfig | 20 ++ drivers/md/Makefile | 1 + drivers/md/dm-default-key.c | 431 ++++++++++++++++++++++++++++++++++++ fs/crypto/inline_crypt.c | 14 +- fs/f2fs/data.c | 6 +- include/linux/blk-crypto.h | 36 +++ include/linux/blk_types.h | 3 + include/linux/fscrypt.h | 14 ++ 11 files changed, 531 insertions(+), 2 deletions(-) create mode 100644 drivers/md/dm-default-key.c
base-commit: c964ced7726294d40913f2127c3f185a92cb4a41
Signature · 1 line
2.47.0
Eric Biggers
maintainerRFC PATCH 1/4 block: export blk-crypto symbols required by dm-default-key
From: Eric Biggers <[email protected]>
bio_crypt_set_ctx(), blk_crypto_init_key(), and blk_crypto_start_using_key() are needed to use inline encryption; see Documentation/block/inline-encryption.rst. Export them so that dm-default-key can use them. The only reason these weren't exported before was that inline encryption was previously used only by fs/crypto/ which is built-in code.
--- block/blk-crypto.c | 3 +++ 1 file changed, 3 insertions(+)
block/blk-crypto.c +3 -0
@@ -104,10 +104,11 @@ void bio_crypt_set_ctx(struct bio *bio, const struct blk_crypto_key *key, bc->bc_key = key;memcpy (bc->bc_dun, dun,sizeof (bc->bc_dun)); bio->bi_crypt_context = bc; } +EXPORT_SYMBOL_GPL (bio_crypt_set_ctx);void __bio_crypt_free_ctx (struct bio *bio) {mempool_free (bio->bi_crypt_context, bio_crypt_ctx_pool); bio->bi_crypt_context =NULL ;
@@ -354,10 +355,11 @@ int blk_crypto_init_key(struct blk_crypto_key *blk_key, const u8 *raw_key, blk_key->size = mode->keysize;memcpy (blk_key->raw, raw_key, mode->keysize);return 0 ; } +EXPORT_SYMBOL_GPL (blk_crypto_init_key);bool blk_crypto_config_supported_natively (struct block_device *bdev,const struct blk_crypto_config *cfg) { return __blk_crypto_cfg_supported(bdev_get_queue(bdev)->crypto_profile,
@@ -396,10 +398,11 @@ int blk_crypto_start_using_key(struct block_device *bdev, {if (blk_crypto_config_supported_natively (bdev, &key->crypto_cfg))return 0 ;return blk_crypto_fallback_start_using_mode (key->crypto_cfg.crypto_mode); } +EXPORT_SYMBOL_GPL (blk_crypto_start_using_key);/** * blk_crypto_evict_key() - Evict a blk_crypto_key from a block_device * @bdev: a block_device on which I/O using the key may have been done * @key: the key to evict
Signature · 1 line
2.47.0
Eric Biggers
maintainerRFC PATCH 2/4 block: add the bi_skip_dm_default_key flag
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Add a flag bi_skip_dm_default_key to struct bio. This flag indicates that dm-default-key should not en/decrypt the bio, due to it targeting the contents of an encrypted file.
When a bio is cloned, copy the bi_skip_dm_default_key flag.
--- block/bio.c | 3 +++ block/blk-crypto-fallback.c | 2 ++ include/linux/blk-crypto.h | 36 ++++++++++++++++++++++++++++++++++++ include/linux/blk_types.h | 3 +++ 4 files changed, 44 insertions(+)
block/bio.c +3 -0
@@ -267,10 +267,13 @@ void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table, bio->bi_iocost_cost =0 ;#endif #endif #ifdef CONFIG_BLK_INLINE_ENCRYPTION bio->bi_crypt_context =NULL ; +#if IS_ENABLED (CONFIG_DM_DEFAULT_KEY ) + bio->bi_skip_dm_default_key = false; +#endif #endif #ifdef CONFIG_BLK_DEV_INTEGRITY bio->bi_integrity =NULL ;#endif bio->bi_vcnt =0 ;
block/blk-crypto-fallback.c +2 -0
@@ -179,10 +179,12 @@ static struct bio *blk_crypto_fallback_clone_bio(struct bio *bio_src)bio_for_each_segment (bv, bio_src, iter) bio->bi_io_vec[bio->bi_vcnt++] = bv;bio_clone_blkg_association (bio, bio_src); +bio_clone_skip_dm_default_key (bio, bio_src); +return bio; } static bool blk_crypto_fallback_alloc_cipher_req(struct blk_crypto_keyslot *slot,
include/linux/blk-crypto.h +36 -0
@@ -110,10 +110,13 @@ static inline bool bio_has_crypt_ctx(struct bio *bio) return false; }#endif /* CONFIG_BLK_INLINE_ENCRYPTION */ +static inline void bio_clone_skip_dm_default_key (struct bio *dst, +const struct bio *src); +int __bio_crypt_clone (struct bio *dst,struct bio *src,gfp_t gfp_mask);/** * bio_crypt_clone - clone bio encryption context * @dst: destination bio * @src: source bio
@@ -125,11 +128,44 @@ int __bio_crypt_clone(struct bio *dst, struct bio *src, gfp_t gfp_mask);* @gfp_mask doesn't include %__GFP_DIRECT_RECLAIM. */ static inline int bio_crypt_clone (struct bio *dst,struct bio *src,gfp_t gfp_mask) { +bio_clone_skip_dm_default_key (dst, src);if (bio_has_crypt_ctx (src))return __bio_crypt_clone (dst, src, gfp_mask);return 0 ; } +#if IS_ENABLED (CONFIG_DM_DEFAULT_KEY ) +static inline void bio_set_skip_dm_default_key (struct bio *bio) +{ + bio->bi_skip_dm_default_key = true; +} + +static inline bool bio_should_skip_dm_default_key (const struct bio *bio) +{ +return bio->bi_skip_dm_default_key; +} + +static inline void bio_clone_skip_dm_default_key (struct bio *dst, +const struct bio *src) +{ + dst->bi_skip_dm_default_key = src->bi_skip_dm_default_key; +} +#else /* CONFIG_DM_DEFAULT_KEY */ +static inline void bio_set_skip_dm_default_key (struct bio *bio) +{ +} + +static inline bool bio_should_skip_dm_default_key (const struct bio *bio) +{ +return false; +} + +static inline void bio_clone_skip_dm_default_key (struct bio *dst, +const struct bio *src) +{ +} +#endif /* !CONFIG_DM_DEFAULT_KEY */ +#endif /* __LINUX_BLK_CRYPTO_H */
include/linux/blk_types.h +3 -0
@@ -247,10 +247,13 @@ struct bio {#endif #endif #ifdef CONFIG_BLK_INLINE_ENCRYPTION struct bio_crypt_ctx *bi_crypt_context; +#if IS_ENABLED (CONFIG_DM_DEFAULT_KEY ) +bool bi_skip_dm_default_key; +#endif #endif #if defined(CONFIG_BLK_DEV_INTEGRITY )struct bio_integrity_payload *bi_integrity;/* data integrity */ #endif
Signature · 1 line
2.47.0
Mikulas Patocka
maintainerRe: [RFC PATCH 2/4] block: add the bi_skip_dm_default_key flag
Hi
What about using the REQ_META flag (it is set on metadata bios and cleared on data bios), instead of adding a new flag with the same meaning?
Mikulas
Quoted 135 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Add a flag
bi_skip_dm_default_keyto struct bio. This flag indicates that dm-default-key should not en/decrypt the bio, due to it targeting the contents of an encrypted file.When a bio is cloned, copy the
bi_skip_dm_default_keyflag.Signed-off-by Eric Biggers <[email protected]>--- block/bio.c | 3 +++ block/blk-crypto-fallback.c | 2 ++ include/linux/blk-crypto.h | 36 ++++++++++++++++++++++++++++++++++++ include/linux/blk_types.h | 3 +++ 4 files changed, 44 insertions(+)block/bio.c +3
-0@@ -267,10 +267,13 @@ void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table, bio->bi_iocost_cost =0 ;#endif #endif #ifdef CONFIG_BLK_INLINE_ENCRYPTION bio->bi_crypt_context =NULL ; +#if IS_ENABLED (CONFIG_DM_DEFAULT_KEY ) + bio->bi_skip_dm_default_key = false; +#endif #endif #ifdef CONFIG_BLK_DEV_INTEGRITY bio->bi_integrity =NULL ;#endif bio->bi_vcnt =0 ;block/blk-crypto-fallback.c +2
-0@@ -179,10 +179,12 @@ static struct bio *blk_crypto_fallback_clone_bio(struct bio *bio_src)bio_for_each_segment (bv, bio_src, iter) bio->bi_io_vec[bio->bi_vcnt++] = bv;bio_clone_blkg_association (bio, bio_src); +bio_clone_skip_dm_default_key (bio, bio_src); +return bio; } static bool blk_crypto_fallback_alloc_cipher_req(struct blk_crypto_keyslot *slot,include/linux/blk-crypto.h +36
-0@@ -110,10 +110,13 @@ static inline bool bio_has_crypt_ctx(struct bio *bio) return false; }#endif /* CONFIG_BLK_INLINE_ENCRYPTION */ +static inline void bio_clone_skip_dm_default_key (struct bio *dst, +const struct bio *src); +int __bio_crypt_clone (struct bio *dst,struct bio *src,gfp_t gfp_mask);/** * bio_crypt_clone - clone bio encryption context * @dst: destination bio * @src: source bio @@ -125,11 +128,44 @@ int __bio_crypt_clone(struct bio *dst, struct bio *src, gfp_t gfp_mask);* @gfp_mask doesn't include %__GFP_DIRECT_RECLAIM. */ static inline int bio_crypt_clone (struct bio *dst,struct bio *src,gfp_t gfp_mask) { +bio_clone_skip_dm_default_key (dst, src);if (bio_has_crypt_ctx (src))return __bio_crypt_clone (dst, src, gfp_mask);return 0 ; } +#if IS_ENABLED (CONFIG_DM_DEFAULT_KEY ) +static inline void bio_set_skip_dm_default_key (struct bio *bio) +{ + bio->bi_skip_dm_default_key = true; +} + +static inline bool bio_should_skip_dm_default_key (const struct bio *bio) +{ +return bio->bi_skip_dm_default_key; +} + +static inline void bio_clone_skip_dm_default_key (struct bio *dst, +const struct bio *src) +{ + dst->bi_skip_dm_default_key = src->bi_skip_dm_default_key; +} +#else /* CONFIG_DM_DEFAULT_KEY */ +static inline void bio_set_skip_dm_default_key (struct bio *bio) +{ +} + +static inline bool bio_should_skip_dm_default_key (const struct bio *bio) +{ +return false; +} + +static inline void bio_clone_skip_dm_default_key (struct bio *dst, +const struct bio *src) +{ +} +#endif /* !CONFIG_DM_DEFAULT_KEY */ +#endif /* __LINUX_BLK_CRYPTO_H */ include/linux/blk_types.h +3
-0@@ -247,10 +247,13 @@ struct bio {#endif #endif #ifdef CONFIG_BLK_INLINE_ENCRYPTION struct bio_crypt_ctx *bi_crypt_context; +#if IS_ENABLED (CONFIG_DM_DEFAULT_KEY ) +bool bi_skip_dm_default_key; +#endif #endif #if defined(CONFIG_BLK_DEV_INTEGRITY )struct bio_integrity_payload *bi_integrity;/* data integrity */ #endif Signature · 1 line
2.47.0
Eric Biggers
maintainerRe: [RFC PATCH 2/4] block: add the bi_skip_dm_default_key flag
Quoted 6 lines · Mikulas Patocka
Hi
What about using the
REQ_METAflag (it is set on metadata bios and cleared on data bios), instead of adding a new flag with the same meaning?Mikulas
REQ_META is a hint and is not used for all metadata.
And while metadata is the main point, more precisely the goal is to encrypt every block that isn't already encrypted. That means that the contents of files that are unencrypted at the filesystem layer are encrypted by dm-default-key too. So technically it's more than just metadata.
To avoid recurring "oops, we forgot to encrypt this" bugs, the right model is really an opt-out flag, not opt-in. And especially not opt-in via something that is currently just a hint and is used as such.
- Eric
Eric Biggers
maintainerRFC PATCH 3/4 dm-default-key: add target for filesystem metadata encryption
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Add a new device-mapper target "dm-default-key" that is similar to dm-crypt but has two main differences:
- It 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.
- It supports a passthrough flag, which will be used by ext4 and f2fs to avoid double encryption of encrypted files. In this setup, dm-default-key provides the "metadata encryption" layer.
The table syntax matches dm-crypt's, but for now only a stripped-down set of parameters is supported.
--- drivers/md/Kconfig | 20 ++ drivers/md/Makefile | 1 + drivers/md/dm-default-key.c | 431 ++++++++++++++++++++++++++++++++++++ 3 files changed, 452 insertions(+) create mode 100644 drivers/md/dm-default-key.c
drivers/md/Kconfig +20 -0
@@ -268,10 +268,30 @@ config DM_CRYPT To compile this code as a module, choose M here: the module will be called dm-crypt. If unsure, say N. +config DM_DEFAULT_KEY + tristate "Default-key target support" + depends on BLK_DEV_DM + depends on BLK_INLINE_ENCRYPTION + # dm-default-key doesn't require -o inlinecrypt, but it does currently + # rely on the inline encryption hooks being built into the kernel. + depends on FS_ENCRYPTION_INLINE_CRYPT + help + This device-mapper target allows you to create a device that + assigns a default encryption key to bios that aren't for the + contents of an encrypted file. + + This ensures that all blocks on-disk will be encrypted with + some key, without the performance hit of file contents being + encrypted twice when fscrypt is used. + + It is only appropriate to use dm-default-key when key + configuration is tightly controlled such that all fscrypt keys + are at least as hard to compromise as the default key. + config DM_SNAPSHOT tristate "Snapshot target" depends on BLK_DEV_DM select DM_BUFIO help
drivers/md/Makefile +1 -0
@@ -49,10 +49,11 @@ obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o obj-$(CONFIG_BLK_DEV_DM_BUILTIN) += dm-builtin.o obj-$(CONFIG_DM_UNSTRIPED) += dm-unstripe.o obj-$(CONFIG_DM_BUFIO) += dm-bufio.o obj-$(CONFIG_DM_BIO_PRISON) += dm-bio-prison.o obj-$(CONFIG_DM_CRYPT) += dm-crypt.o +obj-$(CONFIG_DM_DEFAULT_KEY) += dm-default-key.o obj-$(CONFIG_DM_DELAY) += dm-delay.o obj-$(CONFIG_DM_DUST) += dm-dust.o obj-$(CONFIG_DM_FLAKEY) += dm-flakey.o obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o obj-$(CONFIG_DM_MULTIPATH_QL) += dm-queue-length.o
drivers/md/dm-default-key.c new file +431 -0
431 lines not on this page · raw message
Signature · 1 line
2.47.0
Eric Biggers
maintainerRFC PATCH 4/4 ext4,f2fs: support metadata encryption via dm-default-key
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Set the bi_skip_dm_default_key flag on bios that are targeting the contents of an encrypted file and therefore should not be en/decrypted by dm-default-key.
--- fs/crypto/inline_crypt.c | 14 +++++++++++++- fs/f2fs/data.c | 6 +++++- include/linux/fscrypt.h | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-)
fs/crypto/inline_crypt.c +13 -1
@@ -261,17 +261,22 @@ static void fscrypt_generate_dun(const struct fscrypt_inode_info *ci,* * Normally the bio should be newly allocated (i.e. no pages added yet), as * otherwise fscrypt_mergeable_bio() won't work as intended. * * The encryption context will be freed automatically when the bio is freed. +* +* This function also handles setting bi_skip_dm_default_key when needed. */ void fscrypt_set_bio_crypt_ctx (struct bio *bio,const struct inode *inode,u64 first_lblk,gfp_t gfp_mask) {const struct fscrypt_inode_info *ci;u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE ]; +if (fscrypt_inode_should_skip_dm_default_key (inode)) +bio_set_skip_dm_default_key (bio); +if (!fscrypt_inode_uses_inline_crypto (inode))return ; ci = inode->i_crypt_info;fscrypt_generate_dun (ci, first_lblk, dun);
@@ -342,20 +347,26 @@ EXPORT_SYMBOL_GPL(fscrypt_set_bio_crypt_ctx_bh);* * This function isn't required in cases where crypto-mergeability is ensured in * another way, such as I/O targeting only a single file (and thus a single key) * combined with fscrypt_limit_io_blocks() to ensure DUN contiguity. * +* This function also returns false if the next part of the I/O would need to +* have a different value for the bi_skip_dm_default_key flag. +* * Return: true iff the I/O is mergeable */ bool fscrypt_mergeable_bio (struct bio *bio,const struct inode *inode,u64 next_lblk) {const struct bio_crypt_ctx *bc = bio->bi_crypt_context;u64 next_dun[BLK_CRYPTO_DUN_ARRAY_SIZE ];if (!!bc !=fscrypt_inode_uses_inline_crypto (inode))return false; +if (bio_should_skip_dm_default_key (bio) != +fscrypt_inode_should_skip_dm_default_key (inode)) +return false;if (!bc)return true;/* * Comparing the key pointers is good enough, as all I/O for each key
@@ -385,11 +396,12 @@ bool fscrypt_mergeable_bio_bh(struct bio *bio, {const struct inode *inode;u64 next_lblk;if (!bh_get_inode_and_lblk_num (next_bh, &inode, &next_lblk)) -return !bio->bi_crypt_context; +return !bio->bi_crypt_context && + !bio_should_skip_dm_default_key (bio);return fscrypt_mergeable_bio (bio, inode, next_lblk); }EXPORT_SYMBOL_GPL (fscrypt_mergeable_bio_bh);
fs/f2fs/data.c +5 -1
@@ -484,10 +484,12 @@ static void f2fs_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode,* The f2fs garbage collector sets ->encrypted_page when it wants to * read/write raw data without encryption. */ if (!fio || !fio->encrypted_page)fscrypt_set_bio_crypt_ctx (bio, inode, first_idx, gfp_mask); +else if (fscrypt_inode_should_skip_dm_default_key (inode)) +bio_set_skip_dm_default_key (bio); }static bool f2fs_crypt_mergeable_bio (struct bio *bio,const struct inode *inode,pgoff_t next_idx,const struct f2fs_io_info *fio)
@@ -495,11 +497,13 @@ static bool f2fs_crypt_mergeable_bio(struct bio *bio, const struct inode *inode,/* * The f2fs garbage collector sets ->encrypted_page when it wants to * read/write raw data without encryption. */ if (fio && fio->encrypted_page) -return !bio_has_crypt_ctx (bio); +return !bio_has_crypt_ctx (bio) && + (bio_should_skip_dm_default_key (bio) == +fscrypt_inode_should_skip_dm_default_key (inode));return fscrypt_mergeable_bio (bio, inode, next_idx); } void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, struct bio *bio,
include/linux/fscrypt.h +14 -0
@@ -890,10 +890,24 @@ static inline u64 fscrypt_limit_io_blocks(const struct inode *inode, u64 lblk, {return nr_blocks; }#endif /* !CONFIG_FS_ENCRYPTION_INLINE_CRYPT */ +#if IS_ENABLED (CONFIG_FS_ENCRYPTION ) &&IS_ENABLED (CONFIG_DM_DEFAULT_KEY ) +static inline bool +fscrypt_inode_should_skip_dm_default_key (const struct inode *inode) +{ +return IS_ENCRYPTED (inode) &&S_ISREG (inode->i_mode); +} +#else +static inline bool +fscrypt_inode_should_skip_dm_default_key (const struct inode *inode) +{ +return false; +} +#endif +/** * fscrypt_inode_uses_inline_crypto() - test whether an inode uses inline * encryption * @inode: an inode. If encrypted, its key must be set up. *
Signature · 1 line
2.47.0
Mikulas Patocka
maintainerQuoted 8 lines · Eric Biggers
This series adds "metadata encryption" support to ext4 and f2fs via a new device-mapper target dm-default-key. dm-default-key encrypts all data on a block device that isn't already encrypted by the filesystem.
Except for the passthrough support, dm-default-key is basically the same as the proposed dm-inlinecrypt which omits that feature
(https://lore.kernel.org/dm-devel/[email protected]/).
Quoted 8 lines
I am sending this out for reference, as dm-default-key (which Android has been using for a while) hasn't previously been sent to the lists in full, and there has been interest in it. However, my current impression is that this feature will need to be redesigned as a filesystem native feature in order to make it upstream. If that is indeed the case, then IMO it would make sense to merge dm-inlinecrypt in the mean time instead (or add its functionality to dm-crypt) so that anyone who just wants "dm-crypt + inline encryption hardware" gets a solution for that.
I we merge dm-inlinecrypt, we can't remove it later because users will depend on it. I think it is not sensible to have two targets (dm-inlinecrypt and dm-default-key) that do almost the same thing.
I've got another idea - what about a new target "dm-metadata-switch" that will take two block devices as arguments and it will pass metadata bios to the first device and data bios to the second device - so that the logic to decide where the bio will go would be decoupled from the encryption. Then, you can put dm-crypt or dm-inlinecrypt underneath "dm-metadata-switch".
----------------------
| filesystem |
----------------------
|
V
----------------------
| dm-metadata-switch |
----------------------
| |
V |
------------ |
| dm-crypt | |
------------ |
| |
V V-------------------------
| physical block device |
-------------------------
Mikulas
Eric Biggers
maintainerQuoted 19 lines · Mikulas Patocka
Quoted 8 lines · Eric Biggers
This series adds "metadata encryption" support to ext4 and f2fs via a new device-mapper target dm-default-key. dm-default-key encrypts all data on a block device that isn't already encrypted by the filesystem.
Except for the passthrough support, dm-default-key is basically the same as the proposed dm-inlinecrypt which omits that feature
(https://lore.kernel.org/dm-devel/[email protected]/).Quoted 8 lines
I am sending this out for reference, as dm-default-key (which Android has been using for a while) hasn't previously been sent to the lists in full, and there has been interest in it. However, my current impression is that this feature will need to be redesigned as a filesystem native feature in order to make it upstream. If that is indeed the case, then IMO it would make sense to merge dm-inlinecrypt in the mean time instead (or add its functionality to dm-crypt) so that anyone who just wants "dm-crypt + inline encryption hardware" gets a solution for that.
Quoted 3 lines
I we merge dm-inlinecrypt, we can't remove it later because users will depend on it. I think it is not sensible to have two targets (dm-inlinecrypt and dm-default-key) that do almost the same thing.
The code would not need to be duplicated, though. E.g. dm-default-key functionality could be added as an enable_passthrough option to dm-inlinecrypt. Or the same .c file could register both targets sharing most of the same code.
Quoted 22 lines
I've got another idea - what about a new target "dm-metadata-switch" that will take two block devices as arguments and it will pass metadata bios to the first device and data bios to the second device - so that the logic to decide where the bio will go would be decoupled from the encryption. Then, you can put dm-crypt or dm-inlinecrypt underneath "dm-metadata-switch".
----------------------
| filesystem |
----------------------| V ---------------------- | dm-metadata-switch | ---------------------- | | V | ------------ | | dm-crypt | | ------------ | | | V V
Quoted 3 lines
-------------------------
| physical block device |
-------------------------
Would this have any use case other than what dm-default-key does?
Keep in mind that dm-metadata-switch would have to pass through all sector addresses unchanged. So if you wanted to reuse this to actually put your filesystem metadata on one disk and data on another, this wouldn't be very effective at that, as both data and metadata would take up the full space.
- Eric