Support encryption with reduced device size and data shift.

The only mising bit in library is a check if reduced data
size is smaller than real device size minus data shift.
This commit is contained in:
Ondrej Kozina
2025-05-30 14:59:52 +02:00
parent ed50d30e7e
commit 773ac1ce55

View File

@@ -3071,7 +3071,13 @@ static int reencrypt_init(struct crypt_device *cd,
return -EINVAL;
}
if (!data_size_bytes && params->mode == CRYPT_REENCRYPT_ENCRYPT &&
if (data_size_bytes && params->mode == CRYPT_REENCRYPT_ENCRYPT &&
move_first_segment && data_shift_bytes) {
if (data_size_bytes > device_size_bytes - data_shift_bytes) {
log_err(cd, _("Reduced data size is larger than real device size."));
return -EINVAL;
}
} else if (!data_size_bytes && params->mode == CRYPT_REENCRYPT_ENCRYPT &&
move_first_segment && data_shift_bytes)
data_size_bytes = device_size_bytes - data_shift_bytes;
else if (!data_size_bytes)