Revert "ANDROID: dm: Add wrapped key support in dm-default-key"

This reverts ANDROID-dm-Add-wrapped-key-support-in-dm-default-key.patch
because it is part of the hardware-wrapped keys feature, which conflicts
heavily with upstream refactoring in 5.16.  I've also reworked the
hardware-wrapped key patches when proposing them upstream
(https://lore.kernel.org/linux-block/20210916174928.65529-1-ebiggers@kernel.org).

To unblock the 5.16 merge, revert the hardware-wrapped key patches for
now.  I'll apply a new version of them after the 5.16 merge.

Bug: 160883801
Change-Id: Id169e4ed778f788182e32f40e38c731495869cd3
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit 4f277ec44b)
This commit is contained in:
Eric Biggers
2021-10-21 10:21:45 -07:00
parent fdf3d9ae97
commit eb05f5538c

View File

@@ -9,7 +9,7 @@
#define DM_MSG_PREFIX "default-key"
#define DM_DEFAULT_KEY_MAX_WRAPPED_KEY_SIZE 128
#define DM_DEFAULT_KEY_MAX_KEY_SIZE 64
static const struct dm_default_key_cipher {
const char *name;
@@ -48,7 +48,6 @@ struct default_key_c {
unsigned int sector_size;
unsigned int sector_bits;
struct blk_crypto_key key;
bool is_hw_wrapped;
u64 max_dun;
};
@@ -86,7 +85,7 @@ static int default_key_ctr_optional(struct dm_target *ti,
struct default_key_c *dkc = ti->private;
struct dm_arg_set as;
static const struct dm_arg _args[] = {
{0, 4, "Invalid number of feature args"},
{0, 3, "Invalid number of feature args"},
};
unsigned int opt_params;
const char *opt_string;
@@ -119,8 +118,6 @@ static int default_key_ctr_optional(struct dm_target *ti,
}
} else if (!strcmp(opt_string, "iv_large_sectors")) {
iv_large_sectors = true;
} else if (!strcmp(opt_string, "wrappedkey_v0")) {
dkc->is_hw_wrapped = true;
} else {
ti->error = "Invalid feature arguments";
return -EINVAL;
@@ -148,8 +145,7 @@ static int default_key_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{
struct default_key_c *dkc;
const struct dm_default_key_cipher *cipher;
u8 raw_key[DM_DEFAULT_KEY_MAX_WRAPPED_KEY_SIZE];
unsigned int raw_key_size;
u8 raw_key[DM_DEFAULT_KEY_MAX_KEY_SIZE];
unsigned int dun_bytes;
unsigned long long tmpll;
char dummy;
@@ -182,15 +178,12 @@ static int default_key_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}
/* <key> */
raw_key_size = strlen(argv[1]);
if (raw_key_size > 2 * DM_DEFAULT_KEY_MAX_WRAPPED_KEY_SIZE ||
raw_key_size % 2) {
ti->error = "Invalid keysize";
if (strlen(argv[1]) != 2 * cipher->key_size) {
ti->error = "Incorrect key size for cipher";
err = -EINVAL;
goto bad;
}
raw_key_size /= 2;
if (hex2bin(raw_key, argv[1], raw_key_size) != 0) {
if (hex2bin(raw_key, argv[1], cipher->key_size) != 0) {
ti->error = "Malformed key string";
err = -EINVAL;
goto bad;
@@ -238,8 +231,8 @@ static int default_key_ctr(struct dm_target *ti, unsigned int argc, char **argv)
(dkc->sector_bits - SECTOR_SHIFT);
dun_bytes = DIV_ROUND_UP(fls64(dkc->max_dun), 8);
err = blk_crypto_init_key(&dkc->key, raw_key, raw_key_size,
dkc->is_hw_wrapped, cipher->mode_num,
err = blk_crypto_init_key(&dkc->key, raw_key, cipher->key_size,
false, cipher->mode_num,
dun_bytes, dkc->sector_size);
if (err) {
ti->error = "Error initializing blk-crypto key";
@@ -339,8 +332,6 @@ static void default_key_status(struct dm_target *ti, status_type_t type,
num_feature_args += !!ti->num_discard_bios;
if (dkc->sector_size != SECTOR_SIZE)
num_feature_args += 2;
if (dkc->is_hw_wrapped)
num_feature_args += 1;
if (num_feature_args != 0) {
DMEMIT(" %d", num_feature_args);
if (ti->num_discard_bios)
@@ -349,8 +340,6 @@ static void default_key_status(struct dm_target *ti, status_type_t type,
DMEMIT(" sector_size:%u", dkc->sector_size);
DMEMIT(" iv_large_sectors");
}
if (dkc->is_hw_wrapped)
DMEMIT(" wrappedkey_v0");
}
break;
}