Fix crypt_init_by_name() for dm-crypt with integrity.

Initialization by name for dm-crypt with integrity is always
underlying device for dm-integrity target, not dm-integrity
device itself.

This fixes various problems like refresh command or
device printed in status command.

Fixes: #801
This commit is contained in:
Milan Broz
2023-02-15 10:17:55 +01:00
parent e244c8c543
commit e455110c8e
2 changed files with 16 additions and 4 deletions

View File

@@ -1260,10 +1260,13 @@ static int _init_by_name_crypt(struct crypt_device *cd, const char *name)
r = -EINVAL;
goto out;
}
if (!cd->metadata_device) {
device_free(cd, cd->device);
MOVE_REF(cd->device, tgti->data_device);
}
/*
* Data device for crypt with integrity is not dm-integrity device,
* but always the device underlying dm-integrity.
*/
device_free(cd, cd->device);
MOVE_REF(cd->device, tgti->data_device);
}
/* do not try to lookup LUKS2 header in detached header mode */