* [PATCH] dm-inlinecrypt: emit key type as an optional table argument
@ 2026-11-20 16:36 Anvik Loitongbam
2026-11-20 20:58 ` Eric Biggers
0 siblings, 1 reply; 2+ messages in thread
From: Anvik Loitongbam @ 2026-11-20 16:36 UTC (permalink / raw)
To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
Benjamin Marzinski, dm-devel
Cc: Jonathan Corbet, Shuah Khan, Randy Dunlap, linux-doc,
linux-kernel
inlinecrypt_status() emits ctx->key_type as a positional argument between
the key and iv_offset:
<cipher> <key> <key_type> <iv_offset> <dev_path> <start>
but inlinecrypt_ctr() parses the base table as:
<cipher> <key> <iv_offset> <dev_path> <start>
and keytype, is an optional feature argument parsed by
inlinecrypt_ctr_optional(). Resulting in STATUSTYPE_TABLE output for every
dm-inlinecrypt device to be not reloadable, the constructor reads key_type as
iv_offset and shifts the remaining fields.
Keep the base table in constructor order and emit a non-default key type
as keytype:hw-wrapped in the optional feature list. Raw keys remain the
default and are not emitted, preserving the existing table text for
raw-key devices.
The two dmsetup examples in the documentation acquired
the same extra positional key-type field, so removed it there as well.
Fixes: f9f57971da38 ("dm-inlinecrypt: add support for hardware-wrapped keys")
Cc: stable@vger.kernel.org
Signed-off-by: Anvik Loitongbam <permissiontogallop@gmail.com>
---
diff --git a/Documentation/admin-guide/device-mapper/dm-inlinecrypt.rst b/Documentation/admin-guide/device-mapper/dm-inlinecrypt.rst
index 8258a72f00a8..84dd2e6a1b26 100644
--- a/Documentation/admin-guide/device-mapper/dm-inlinecrypt.rst
+++ b/Documentation/admin-guide/device-mapper/dm-inlinecrypt.rst
@@ -119,11 +119,11 @@ using dmsetup
#!/bin/sh
# Create a inlinecrypt device using dmsetup
- dmsetup create inlinecrypt1 --table "0 `blockdev --getsz $1` inlinecrypt aes-xts-plain64 babebabebabebabebabebabebabebabebabebabebabebabebabebabebabebabe 0 0 $1 0 1 keytype:raw"
+ dmsetup create inlinecrypt1 --table "0 `blockdev --getsz $1` inlinecrypt aes-xts-plain64 babebabebabebabebabebabebabebabebabebabebabebabebabebabebabebabe 0 $1 0 1 keytype:raw"
::
#!/bin/sh
# Create a inlinecrypt device using dmsetup when encryption key is stored in keyring service
- dmsetup create inlinecrypt2 --table "0 `blockdev --getsz $1` inlinecrypt aes-xts-plain64 :64:logon:fde:dminlinecrypt_test_key 0 0 $1 0 1 keytype:raw"
+ dmsetup create inlinecrypt2 --table "0 `blockdev --getsz $1` inlinecrypt aes-xts-plain64 :64:logon:fde:dminlinecrypt_test_key 0 $1 0 1 keytype:raw"
diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c
index 3479dfe5f708..c4a0501e7b9a 100644
--- a/drivers/md/dm-inlinecrypt.c
+++ b/drivers/md/dm-inlinecrypt.c
@@ -522,15 +522,20 @@ static void inlinecrypt_status(struct dm_target *ti, status_type_t type,
* the returned table. Userspace is responsible for redacting
* the key when needed.
*/
- DMEMIT("%s %*phN %u %llu %s %llu", ctx->cipher_string,
- ctx->key.size, ctx->key.bytes,
- ctx->key_type, ctx->iv_offset,
+ DMEMIT("%s %*phN %llu %s %llu", ctx->cipher_string,
+ ctx->key.size, ctx->key.bytes, ctx->iv_offset,
ctx->dev->name, ctx->start);
num_feature_args += !!ti->num_discard_bios;
+ if (ctx->key_type != BLK_CRYPTO_KEY_TYPE_RAW)
+ num_feature_args++;
if (ctx->sector_size != SECTOR_SIZE)
num_feature_args += 2;
if (num_feature_args != 0) {
DMEMIT(" %d", num_feature_args);
+ if (ctx->key_type != BLK_CRYPTO_KEY_TYPE_RAW)
+ DMEMIT(" keytype:%s",
+ ctx->key_type == BLK_CRYPTO_KEY_TYPE_HW_WRAPPED ?
+ "hw-wrapped" : "raw");
if (ti->num_discard_bios)
DMEMIT(" allow_discards");
if (ctx->sector_size != SECTOR_SIZE) {
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] dm-inlinecrypt: emit key type as an optional table argument
2026-11-20 16:36 [PATCH] dm-inlinecrypt: emit key type as an optional table argument Anvik Loitongbam
@ 2026-11-20 20:58 ` Eric Biggers
0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2026-11-20 20:58 UTC (permalink / raw)
To: Anvik Loitongbam
Cc: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
Benjamin Marzinski, dm-devel, Jonathan Corbet, Shuah Khan,
Randy Dunlap, linux-doc, linux-kernel
On Fri, Nov 20, 2026 at 10:06:01PM +0530, Anvik Loitongbam wrote:
> inlinecrypt_status() emits ctx->key_type as a positional argument between
> the key and iv_offset:
>
> <cipher> <key> <key_type> <iv_offset> <dev_path> <start>
>
> but inlinecrypt_ctr() parses the base table as:
>
> <cipher> <key> <iv_offset> <dev_path> <start>
>
> and keytype, is an optional feature argument parsed by
> inlinecrypt_ctr_optional(). Resulting in STATUSTYPE_TABLE output for every
> dm-inlinecrypt device to be not reloadable, the constructor reads key_type as
> iv_offset and shifts the remaining fields.
>
> Keep the base table in constructor order and emit a non-default key type
> as keytype:hw-wrapped in the optional feature list. Raw keys remain the
> default and are not emitted, preserving the existing table text for
> raw-key devices.
>
> The two dmsetup examples in the documentation acquired
> the same extra positional key-type field, so removed it there as well.
>
> Fixes: f9f57971da38 ("dm-inlinecrypt: add support for hardware-wrapped keys")
> Cc: stable@vger.kernel.org
> Signed-off-by: Anvik Loitongbam <permissiontogallop@gmail.com>
The original Sashiko review of this commit mentioned this bug already
(https://sashiko.dev/#/patchset/20260525121348.1321282-2-linlin.zhang%40oss.qualcomm.com).
Might be worth adding a Reported-by if you found it from there.
> + if (ctx->key_type != BLK_CRYPTO_KEY_TYPE_RAW)
> + num_feature_args++;
> if (ctx->sector_size != SECTOR_SIZE)
> num_feature_args += 2;
> if (num_feature_args != 0) {
> DMEMIT(" %d", num_feature_args);
> + if (ctx->key_type != BLK_CRYPTO_KEY_TYPE_RAW)
> + DMEMIT(" keytype:%s",
> + ctx->key_type == BLK_CRYPTO_KEY_TYPE_HW_WRAPPED ?
> + "hw-wrapped" : "raw");
The "raw" fallback case doesn't make much sense, because it was just
checked above that it is *not* raw. So if it is ever reached due to a
new enum value it will be wrong anyway. Maybe just leave that out and
simply do DMEMIT(" keytype:hw-wrapped").
Otherwise this fix looks good, thanks.
- Eric
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-20 20:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 16:36 [PATCH] dm-inlinecrypt: emit key type as an optional table argument Anvik Loitongbam
2026-11-20 20:58 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox