Disable DIRECT_IO for LUKS header with unaligned keyslots.

Fixes issue#287.

Such a header is very rare, it is not worth to do more detection here.
This commit is contained in:
Milan Broz
2016-03-23 13:44:37 +01:00
parent 6894701392
commit d7a224e47a
3 changed files with 17 additions and 0 deletions

View File

@@ -545,6 +545,16 @@ int LUKS_read_phdr(struct luks_phdr *hdr,
if (!r)
r = LUKS_check_device_size(ctx, hdr->keyBytes);
/*
* Cryptsetup 1.0.0 did not align keyslots to 4k (very rare version).
* Disable direct-io to avoid possible IO errors if underlying device
* has bigger sector size.
*/
if (!r && hdr->keyblock[0].keyMaterialOffset * SECTOR_SIZE < LUKS_ALIGN_KEYSLOTS) {
log_dbg("Old unaligned LUKS keyslot detected, disabling direct-io.");
device_disable_direct_io(device);
}
close(devfd);
return r;
}