mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-09 01:40:00 +01:00
Check and allocate header early so wipe fails only for IO errors.
The device_check is done in header write functions, but these are not recached in normal format path as wipe call is called earlier. Call the device check also from wipe function to get better error description. This situation happens for example when a block device is too small (regular file can be enlarged by falloc(); block device cannot).
This commit is contained in:
@@ -1228,6 +1228,10 @@ int LUKS_wipe_header_areas(struct luks_phdr *hdr,
|
||||
uint64_t offset, length;
|
||||
size_t wipe_block;
|
||||
|
||||
r = LUKS_check_device_size(ctx, hdr, 1);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
/* Wipe complete header, keyslots and padding areas with zeroes. */
|
||||
offset = 0;
|
||||
length = (uint64_t)hdr->payloadOffset * SECTOR_SIZE;
|
||||
|
||||
@@ -362,6 +362,10 @@ int LUKS2_wipe_header_areas(struct crypt_device *cd,
|
||||
wipe_block = 4096;
|
||||
}
|
||||
|
||||
r = device_check_size(cd, crypt_metadata_device(cd), length, 1);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
log_dbg(cd, "Wiping LUKS areas (0x%06" PRIx64 " - 0x%06" PRIx64") with zeroes.",
|
||||
offset, length + offset);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user