[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v11 03/12] parallels: Fix image_end_offset and data_end after out
From: |
Alexander Ivanov |
Subject: |
[PATCH v11 03/12] parallels: Fix image_end_offset and data_end after out-of-image check |
Date: |
Mon, 24 Apr 2023 11:31:38 +0200 |
Set data_end to the end of the last cluster inside the image. In such a
way we can be sure that corrupted offsets in the BAT can't affect on the
image size. If there are no allocated clusters set image_end_offset by
data_end.
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
---
block/parallels.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/block/parallels.c b/block/parallels.c
index 4d6284a314..dec4fe1f06 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -490,7 +490,13 @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult
*res,
}
}
- res->image_end_offset = high_off + s->cluster_size;
+ if (high_off == 0) {
+ res->image_end_offset = s->data_end << BDRV_SECTOR_BITS;
+ } else {
+ res->image_end_offset = high_off + s->cluster_size;
+ s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS;
+ }
+
if (size > res->image_end_offset) {
int64_t count;
count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
--
2.34.1
- [PATCH v11 03/12] parallels: Fix image_end_offset and data_end after out-of-image check, (continued)
- [PATCH v11 03/12] parallels: Fix image_end_offset and data_end after out-of-image check, Alexander Ivanov, 2023/04/24
- [PATCH v11 04/12] parallels: create parallels_set_bat_entry_helper() to assign BAT value, Alexander Ivanov, 2023/04/24
- [PATCH v11 01/12] parallels: Out of image offset in BAT leads to image inflation, Alexander Ivanov, 2023/04/24
- Re: [PATCH v11 00/12] parallels: Refactor the code of images checks and fix a bug, Alexander Ivanov, 2023/04/24
- [PATCH v11 00/12] parallels: Refactor the code of images checks and fix a bug, Alexander Ivanov, 2023/04/24
- [PATCH v11 02/12] parallels: Fix high_off calculation in parallels_co_check(), Alexander Ivanov, 2023/04/24
- [PATCH v11 07/12] parallels: Move check of cluster outside image to a separate function, Alexander Ivanov, 2023/04/24
- [PATCH v11 01/12] parallels: Out of image offset in BAT leads to image inflation, Alexander Ivanov, 2023/04/24
- [PATCH v11 08/12] parallels: Fix statistics calculation, Alexander Ivanov, 2023/04/24
- [PATCH v11 05/12] parallels: Use generic infrastructure for BAT writing in parallels_co_check(), Alexander Ivanov, 2023/04/24
- [PATCH v11 03/12] parallels: Fix image_end_offset and data_end after out-of-image check,
Alexander Ivanov <=
- [PATCH v11 06/12] parallels: Move check of unclean image to a separate function, Alexander Ivanov, 2023/04/24
- [PATCH v11 09/12] parallels: Move check of leaks to a separate function, Alexander Ivanov, 2023/04/24
- [PATCH v11 12/12] parallels: Incorrect condition in out-of-image check, Alexander Ivanov, 2023/04/24
- [PATCH v11 11/12] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD, Alexander Ivanov, 2023/04/24
- [PATCH v11 10/12] parallels: Move statistic collection to a separate function, Alexander Ivanov, 2023/04/24
- [PATCH v11 04/12] parallels: create parallels_set_bat_entry_helper() to assign BAT value, Alexander Ivanov, 2023/04/24
- Re: [PATCH v11 00/12] parallels: Refactor the code of images checks and fix a bug, Denis V. Lunev, 2023/04/26
- Re: [PATCH v11 00/12] parallels: Refactor the code of images checks and fix a bug, Hanna Czenczek, 2023/04/28