Align legacy keyslot temporary device according to keyslot alignment.

For some strange filesystems (nfs) we get big block size (1MB).

For temporary keyslot devices this mapping does not make sense and
can cause problem with detached headers that are smaller (contains
exactly the slot size).
This commit is contained in:
Milan Broz
2017-12-06 13:41:32 +01:00
parent 767ed40b75
commit e0cacef52e

View File

@@ -67,7 +67,7 @@ static int LUKS_endec_template(char *src, size_t srcLength,
}
};
int r, devfd = -1;
size_t bsize, alignment;
size_t bsize, keyslot_alignment, alignment;
log_dbg("Using dmcrypt to access keyslot area.");
@@ -76,7 +76,11 @@ static int LUKS_endec_template(char *src, size_t srcLength,
if (!bsize || !alignment)
return -EINVAL;
dmd.size = size_round_up(srcLength, bsize) / SECTOR_SIZE;
if (bsize > LUKS_ALIGN_KEYSLOTS)
keyslot_alignment = LUKS_ALIGN_KEYSLOTS;
else
keyslot_alignment = bsize;
dmd.size = size_round_up(srcLength, keyslot_alignment) / SECTOR_SIZE;
if (mode == O_RDONLY)
dmd.flags |= CRYPT_ACTIVATE_READONLY;