mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Opal: Require locking range attributes in range check function.
The check will be required mandatory in the next patch.
This commit is contained in:
@@ -297,12 +297,12 @@ static int opal_range_check_attributes_fd(struct crypt_device *cd,
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(cd);
|
assert(cd);
|
||||||
assert(vk);
|
assert(vk);
|
||||||
|
assert(check_offset_sectors);
|
||||||
|
assert(check_length_sectors);
|
||||||
|
|
||||||
if (check_offset_sectors || check_length_sectors) {
|
r = opal_geometry_fd(cd, fd, NULL, &opal_block_bytes, NULL, NULL);
|
||||||
r = opal_geometry_fd(cd, fd, NULL, &opal_block_bytes, NULL, NULL);
|
if (r != OPAL_STATUS_SUCCESS)
|
||||||
if (r != OPAL_STATUS_SUCCESS)
|
return -EINVAL;
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
lrs = crypt_safe_alloc(sizeof(*lrs));
|
lrs = crypt_safe_alloc(sizeof(*lrs));
|
||||||
if (!lrs)
|
if (!lrs)
|
||||||
@@ -329,22 +329,18 @@ static int opal_range_check_attributes_fd(struct crypt_device *cd,
|
|||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
|
|
||||||
if (check_offset_sectors) {
|
offset = lrs->range_start * opal_block_bytes / SECTOR_SIZE;
|
||||||
offset = lrs->range_start * opal_block_bytes / SECTOR_SIZE;
|
if (offset != *check_offset_sectors) {
|
||||||
if (offset != *check_offset_sectors) {
|
log_err(cd, _("OPAL range %d offset %" PRIu64 " does not match expected values %" PRIu64 "."),
|
||||||
log_err(cd, _("OPAL range %d offset %" PRIu64 " does not match expected values %" PRIu64 "."),
|
segment_number, offset, *check_offset_sectors);
|
||||||
segment_number, offset, *check_offset_sectors);
|
r = -EINVAL;
|
||||||
r = -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_length_sectors) {
|
length = lrs->range_length * opal_block_bytes / SECTOR_SIZE;
|
||||||
length = lrs->range_length * opal_block_bytes / SECTOR_SIZE;
|
if (length != *check_length_sectors) {
|
||||||
if (length != *check_length_sectors) {
|
log_err(cd, _("OPAL range %d length %" PRIu64" does not match device length %" PRIu64 "."),
|
||||||
log_err(cd, _("OPAL range %d length %" PRIu64" does not match device length %" PRIu64 "."),
|
segment_number, length, *check_length_sectors);
|
||||||
segment_number, length, *check_length_sectors);
|
r = -EINVAL;
|
||||||
r = -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lrs->RLE || !lrs->WLE) {
|
if (!lrs->RLE || !lrs->WLE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user