mirror of
https://github.com/a52xq-dev/kernel.git
synced 2026-10-18 21:58:11 +07:00
ANDROID: dm: add support for passing through inline crypto support
Update the device-mapper core to support exposing the inline crypto support of the underlying device(s) through the device-mapper device. This works by creating a "passthrough keyslot manager" for the dm device, which declares support for the set of (crypto_mode, data_unit_size) combos which all the underlying devices support. When a supported combo is used, the bio cloning code handles cloning the crypto context to the bios for all the underlying devices. When an unsupported combo is used, the blk-crypto fallback is used as usual. Crypto support on each underlying device is ignored unless the corresponding dm target opts into exposing it. This is needed because for inline crypto to semantically operate on the original bio, the data must not be transformed by the dm target. Thus, targets like dm-linear can expose crypto support of the underlying device, but targets like dm-crypt can't. (dm-crypt could use inline crypto itself, though.) When a key is evicted from the dm device, it is evicted from all underlying devices. Bug: 137270441 Bug: 147814592 Change-Id: If28b574f2e28268db5eb9f325d4cf8f96cb63e3f Signed-off-by: Eric Biggers <ebiggers@google.com>
This commit is contained in:
parent
e65d08ae68
commit
44e1174c18
1 changed files with 190 additions and 1 deletions
|
|
@ -492,6 +492,34 @@ struct keyslot_manager *keyslot_manager_create_passthrough(
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(keyslot_manager_create_passthrough);
|
||||
|
||||
/**
|
||||
* keyslot_manager_intersect_modes() - restrict supported modes by child device
|
||||
* @parent: The keyslot manager for parent device
|
||||
* @child: The keyslot manager for child device, or NULL
|
||||
*
|
||||
* Clear any crypto mode support bits in @parent that aren't set in @child.
|
||||
* If @child is NULL, then all parent bits are cleared.
|
||||
*
|
||||
* Only use this when setting up the keyslot manager for a layered device,
|
||||
* before it's been exposed yet.
|
||||
*/
|
||||
void keyslot_manager_intersect_modes(struct keyslot_manager *parent,
|
||||
const struct keyslot_manager *child)
|
||||
{
|
||||
if (child) {
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(child->crypto_mode_supported); i++) {
|
||||
parent->crypto_mode_supported[i] &=
|
||||
child->crypto_mode_supported[i];
|
||||
}
|
||||
} else {
|
||||
memset(parent->crypto_mode_supported, 0,
|
||||
sizeof(parent->crypto_mode_supported));
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(keyslot_manager_intersect_modes);
|
||||
|
||||
/**
|
||||
* keyslot_manager_derive_raw_secret() - Derive software secret from wrapped key
|
||||
* @ksm: The keyslot manager
|
||||
|
|
|
|||
Loading…
Reference in a new issue