From 10e5ab1a871e227dbd648ff27e5c2ba5150432d4 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Fri, 8 Aug 2025 11:15:32 +0200 Subject: [PATCH] tcrypt: Fix detecting status of chained modes The function dm_uuid_cmp cannot be used for TCRYPT, it expects LUKS UUID, not a device name. Fixes: #952 --- lib/tcrypt/tcrypt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/tcrypt/tcrypt.c b/lib/tcrypt/tcrypt.c index f8fe5ddd..2fd95399 100644 --- a/lib/tcrypt/tcrypt.c +++ b/lib/tcrypt/tcrypt.c @@ -928,14 +928,16 @@ out: static bool is_tcrypt_subdev(const char *dm_uuid, const char *base_uuid) { - assert(base_uuid); + const char *base_uuid_name; - if (!dm_uuid) + assert(base_uuid); + base_uuid_name = strchr(base_uuid, '-'); + + if (!dm_uuid || !base_uuid_name) return false; if (!strncmp(dm_uuid, "SUBDEV-", 7)) - /* dm_uuid + 6 because function requires dm_uuid to contain '-' */ - return !dm_uuid_cmp(dm_uuid + 6, strchr(base_uuid, '-')); + return !strncmp(dm_uuid + 6, base_uuid_name, strlen(base_uuid_name)); /* * FIXME: Drop after shift to dependency based deactivation (CRYPT_SUBDEV)