mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Create dm-integrity with CRYPT_SUBDEV prefix.
When activating dm-integrity device underneath dm-crypt with LUKS2 authenticated encryption mode, annotate the device correctly with CRYPT_SUBDEV prefix. This will help us to clearly identify dependent device underneath LUKS2 top level device and we can unify the deactivation code in future releases. We have general code deactivating dependent devices already for LUKS2 reencrytion. Deactivating newly created devices with pre 2.8.0 cryptsetup will issue warning about missing devices but the deactivation will succeed.
This commit is contained in:
@@ -2923,6 +2923,18 @@ int LUKS2_deactivate(struct crypt_device *cd, const char *name, struct luks2_hdr
|
||||
ret = 0;
|
||||
dep = deps;
|
||||
while (*dep) {
|
||||
/*
|
||||
* FIXME: dm-integrity has now proper SUBDEV prefix so
|
||||
* it would be deactivated here, but due to specific
|
||||
* dm_remove_device(iname) above the iname device
|
||||
* is no longer active. This will be fixed when
|
||||
* we switch to SUBDEV deactivation after 2.8 release.
|
||||
*/
|
||||
if (iname && !strcmp(*dep, iname)) {
|
||||
dep++;
|
||||
continue;
|
||||
}
|
||||
|
||||
log_dbg(cd, "Deactivating LUKS2 dependent device %s.", *dep);
|
||||
r = dm_query_device(cd, *dep, DM_ACTIVE_CRYPT_KEY | DM_ACTIVE_CRYPT_KEYSIZE, &dmdc);
|
||||
if (r < 0) {
|
||||
|
||||
12
lib/setup.c
12
lib/setup.c
@@ -3269,7 +3269,15 @@ static int _compare_device_types(struct crypt_device *cd,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (isLUKS2(cd->type) && !strncmp("INTEGRITY-", tgt->uuid, strlen("INTEGRITY-"))) {
|
||||
/*
|
||||
* FIXME: The CRYPT_SUBDEV prefix should be enough but we need
|
||||
* to keep INTEGRITY- for dm-integrity subdevices opened with
|
||||
* cryptsetup version < 2.8.0. Drop the INTEGRITY condition
|
||||
* in next Y release.
|
||||
*/
|
||||
if (isLUKS2(cd->type) &&
|
||||
(!strncmp("INTEGRITY-", tgt->uuid, strlen("INTEGRITY-")) ||
|
||||
!strncmp(CRYPT_SUBDEV, tgt->uuid, strlen(CRYPT_SUBDEV)))) {
|
||||
if (dm_uuid_cmp(tgt->uuid, src->uuid)) {
|
||||
log_dbg(cd, "LUKS UUID mismatch.");
|
||||
return -EINVAL;
|
||||
@@ -4921,7 +4929,7 @@ static int _create_device_with_integrity(struct crypt_device *cd,
|
||||
|
||||
device_check = dmd->flags & CRYPT_ACTIVATE_SHARED ? DEV_OK : DEV_EXCL;
|
||||
|
||||
r = INTEGRITY_activate_dmd_device(cd, iname, CRYPT_INTEGRITY, dmdi, 0);
|
||||
r = INTEGRITY_activate_dmd_device(cd, iname, CRYPT_SUBDEV, dmdi, 0);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user