Skip to content

Commit 6c7c8d3

Browse files
onikombroz
authored andcommitted
Fix bug in parsing of tcrypt device in crypt_init_by_name.
When TCRYPT subdevices was moved to use SUBDEV dm uuid prefix we did not correctly modified the TCRYPT_status_one routine to correctly expect the SUBDEV uuid prefix. Fixes: cf630f5 Fixes: #952.
1 parent b6ddaa4 commit 6c7c8d3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/tcrypt/tcrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ static int TCRYPT_status_one(struct crypt_device *cd, const char *name,
10231023

10241024
r = 0;
10251025

1026-
if (!strncmp(dmd.uuid, base_uuid, strlen(base_uuid))) {
1026+
if (is_tcrypt_subdev(dmd.uuid, base_uuid)) {
10271027
if ((c = strchr(tgt->u.crypt.cipher, '-')))
10281028
*c = '\0';
10291029
strcat(cipher, "-");

tests/api-test.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,15 @@ static void TcryptTest(void)
18481848
OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, NULL, 0, CRYPT_ACTIVATE_READONLY));
18491849
CRYPT_FREE(cd);
18501850

1851+
// Check tcrypt can correctly parse parameters from active stacked cipher device
1852+
OK_(crypt_init_by_name(&cd, CDEVICE_1));
1853+
OK_(strcmp(crypt_get_cipher(cd), "aes-twofish-serpent"));
1854+
OK_(strcmp(crypt_get_cipher_mode(cd), "xts-plain64"));
1855+
EQ_(crypt_get_volume_key_size(cd), 192);
1856+
/* just check if it correctly parsed data device down to a loopback device */
1857+
OK_(strncmp(crypt_get_device_name(cd) ?: "", "/dev/loop", 9));
1858+
CRYPT_FREE(cd);
1859+
18511860
// Deactivate the whole chain
18521861
EQ_(crypt_status(NULL, CDEVICE_1 "_1"), CRYPT_BUSY);
18531862
OK_(crypt_deactivate(NULL, CDEVICE_1));

0 commit comments

Comments
 (0)