From 330f9daadee8d409177bdd85a2b293b67a23b874 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Tue, 9 Jul 2019 15:42:27 +0200 Subject: [PATCH] Pass max_hotzone_size inside reencryption parameters in sectors. --- lib/luks2/luks2_reencrypt.c | 6 +++--- src/cryptsetup.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/luks2/luks2_reencrypt.c b/lib/luks2/luks2_reencrypt.c index 1cccf960..501b7476 100644 --- a/lib/luks2/luks2_reencrypt.c +++ b/lib/luks2/luks2_reencrypt.c @@ -886,10 +886,10 @@ static int _reenc_load(struct crypt_device *cd, struct luks2_hdr *hdr, struct lu return -EINVAL; log_dbg(cd, "Requested hotzone size: %" PRIu64 ", requested device size: %" PRIu64 - ", calculated alignment: %zu", params->max_hotzone_size, + ", calculated alignment: %zu", params->max_hotzone_size << SECTOR_SHIFT, params->device_size << SECTOR_SHIFT, rh->alignment); - if (params->max_hotzone_size % rh->alignment) { + if ((params->max_hotzone_size << SECTOR_SHIFT) % rh->alignment) { log_err(cd, _("Hotzone size must be multiple of calculated zone alignment (%zu bytes)."), rh->alignment); return -EINVAL; } @@ -952,7 +952,7 @@ static int _reenc_load(struct crypt_device *cd, struct luks2_hdr *hdr, struct lu } else rh->fixed_length = false; - rh->length = LUKS2_get_reencrypt_length(hdr, rh, area_length, params->max_hotzone_size); + rh->length = LUKS2_get_reencrypt_length(hdr, rh, area_length, params->max_hotzone_size << SECTOR_SHIFT); if (LUKS2_get_reencrypt_offset(hdr, rh->direction, device_size, &rh->length, &rh->offset)) { log_dbg(cd, "Failed to get reencryption offset."); return -EINVAL; diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 096e4214..4b088017 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -2546,7 +2546,7 @@ static int action_reencrypt_load(struct crypt_device *cd) struct crypt_params_reencrypt params = { .resilience = opt_resilience_mode, .hash = opt_resilience_hash, - .max_hotzone_size = opt_hotzone_size, + .max_hotzone_size = opt_hotzone_size / SECTOR_SIZE, .device_size = opt_device_size / SECTOR_SIZE, .flags = CRYPT_REENCRYPT_RESUME_ONLY }; @@ -2590,7 +2590,7 @@ static int action_encrypt_luks2(struct crypt_device **cd) .direction = opt_data_shift < 0 ? CRYPT_REENCRYPT_BACKWARD : CRYPT_REENCRYPT_FORWARD, .resilience = opt_resilience_mode, .hash = opt_resilience_hash, - .max_hotzone_size = opt_hotzone_size, + .max_hotzone_size = opt_hotzone_size / SECTOR_SIZE, .device_size = opt_device_size / SECTOR_SIZE, .luks2 = &luks2_params, .flags = CRYPT_REENCRYPT_INITIALIZE_ONLY @@ -2754,7 +2754,7 @@ static int action_decrypt_luks2(struct crypt_device *cd) .hash = opt_resilience_hash, .data_shift = imaxabs(opt_data_shift) / SECTOR_SIZE, .device_size = opt_device_size / SECTOR_SIZE, - .max_hotzone_size = opt_hotzone_size, + .max_hotzone_size = opt_hotzone_size / SECTOR_SIZE, }; size_t passwordLen; @@ -2966,7 +2966,7 @@ static int action_reencrypt_luks2(struct crypt_device *cd) .resilience = opt_data_shift ? "datashift" : opt_resilience_mode, .hash = opt_resilience_hash, .data_shift = imaxabs(opt_data_shift) / SECTOR_SIZE, - .max_hotzone_size = opt_hotzone_size, + .max_hotzone_size = opt_hotzone_size / SECTOR_SIZE, .device_size = opt_device_size / SECTOR_SIZE, .luks2 = &luks2_params, };