mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-12 11:20:10 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user