Check HW OPAL range parameters in proper units.

The opal_range_check_attributes_fd function expected both
offset and length parameters of a LR to be passed in sectors (512B).
During format we passed it wrongly in OPAL blocks which caused
bogus check provided OPAL block size was not 512B.

Fixes: #871.
This commit is contained in:
Ondrej Kozina
2024-03-25 15:22:40 +01:00
parent 8655093cb7
commit a462dbeb4e
3 changed files with 22 additions and 12 deletions

View File

@@ -2556,7 +2556,8 @@ int crypt_format_luks2_opal(struct crypt_device *cd,
r = opal_setup_ranges(cd, crypt_data_device(cd), user_key ?: cd->volume_key,
range_offset_blocks, range_size_bytes / opal_block_bytes,
opal_segment_number, opal_params->admin_key, opal_params->admin_key_size);
opal_block_bytes, opal_segment_number,
opal_params->admin_key, opal_params->admin_key_size);
if (r < 0) {
if (r == -EPERM)
log_err(cd, _("Incorrect OPAL Admin key."));