Do not allow resize if device size is not aligned to sector size.

This commit is contained in:
Milan Broz
2017-10-03 13:49:16 +02:00
parent 8dc35a7906
commit cc5c91158d
2 changed files with 17 additions and 0 deletions

View File

@@ -2049,6 +2049,14 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size)
if (r)
goto out;
if (new_size & ((dmd.u.crypt.sector_size >> SECTOR_SHIFT) - 1)) {
log_err(cd, _("Device %s size is not aligned to requested sector size (%u bytes).\n"),
crypt_get_device_name(cd), (unsigned)dmd.u.crypt.sector_size);
r = -EINVAL;
goto out;
}
if (new_size == dmd.size) {
log_dbg("Device has already requested size %" PRIu64
" sectors.", dmd.size);