mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-12 03:10:08 +01:00
Workaround for dm-integrity kernel table bug.
Some kernels show invalid dm-integrity table if suberblock contains "recalculate" bit. We can workaround that by setting recalculate option in table (kernel uses bits from superblock anyway), so the table displayed is always correct. Fixes: #538
This commit is contained in:
@@ -213,7 +213,7 @@ int INTEGRITY_create_dmd_device(struct crypt_device *cd,
|
|||||||
struct volume_key *journal_crypt_key,
|
struct volume_key *journal_crypt_key,
|
||||||
struct volume_key *journal_mac_key,
|
struct volume_key *journal_mac_key,
|
||||||
struct crypt_dm_active_device *dmd,
|
struct crypt_dm_active_device *dmd,
|
||||||
uint32_t flags)
|
uint32_t flags, uint32_t sb_flags)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@@ -224,6 +224,10 @@ int INTEGRITY_create_dmd_device(struct crypt_device *cd,
|
|||||||
.flags = flags,
|
.flags = flags,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Workaround for kernel dm-integrity table bug */
|
||||||
|
if (sb_flags & SB_FLAG_RECALCULATING)
|
||||||
|
dmd->flags |= CRYPT_ACTIVATE_RECALCULATE;
|
||||||
|
|
||||||
r = INTEGRITY_data_sectors(cd, crypt_metadata_device(cd),
|
r = INTEGRITY_data_sectors(cd, crypt_metadata_device(cd),
|
||||||
crypt_get_data_offset(cd) * SECTOR_SIZE, &dmd->size);
|
crypt_get_data_offset(cd) * SECTOR_SIZE, &dmd->size);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@@ -287,7 +291,8 @@ int INTEGRITY_activate(struct crypt_device *cd,
|
|||||||
uint32_t flags, uint32_t sb_flags)
|
uint32_t flags, uint32_t sb_flags)
|
||||||
{
|
{
|
||||||
struct crypt_dm_active_device dmd = {};
|
struct crypt_dm_active_device dmd = {};
|
||||||
int r = INTEGRITY_create_dmd_device(cd, params, vk, journal_crypt_key, journal_mac_key, &dmd, flags);
|
int r = INTEGRITY_create_dmd_device(cd, params, vk, journal_crypt_key,
|
||||||
|
journal_mac_key, &dmd, flags, sb_flags);
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ int INTEGRITY_create_dmd_device(struct crypt_device *cd,
|
|||||||
struct volume_key *journal_crypt_key,
|
struct volume_key *journal_crypt_key,
|
||||||
struct volume_key *journal_mac_key,
|
struct volume_key *journal_mac_key,
|
||||||
struct crypt_dm_active_device *dmd,
|
struct crypt_dm_active_device *dmd,
|
||||||
uint32_t flags);
|
uint32_t flags, uint32_t sb_flags);
|
||||||
|
|
||||||
int INTEGRITY_activate_dmd_device(struct crypt_device *cd,
|
int INTEGRITY_activate_dmd_device(struct crypt_device *cd,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
|||||||
@@ -2156,7 +2156,7 @@ int LUKS2_activate(struct crypt_device *cd,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = INTEGRITY_create_dmd_device(cd, NULL, NULL, NULL, NULL, &dmdi, dmd.flags);
|
r = INTEGRITY_create_dmd_device(cd, NULL, NULL, NULL, NULL, &dmdi, dmd.flags, 0);
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user