[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/17] parallels: Fix image_end_offset and data_end after out-of-i
From: |
Hanna Czenczek |
Subject: |
[PULL 07/17] parallels: Fix image_end_offset and data_end after out-of-image check |
Date: |
Mon, 5 Jun 2023 17:45:31 +0200 |
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
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>
Message-Id: <20230424093147.197643-4-alexander.ivanov@virtuozzo.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
---
block/parallels.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/block/parallels.c b/block/parallels.c
index 204d20685b..ea382e8382 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.40.1
- Re: [PULL 05/17] parallels: Out of image offset in BAT leads to image inflation, (continued)
[PULL 06/17] parallels: Fix high_off calculation in parallels_co_check(), Hanna Czenczek, 2023/06/05
[PULL 04/17] iotests/iov-padding: New test, Hanna Czenczek, 2023/06/05
[PULL 11/17] parallels: Move check of cluster outside image to a separate function, Hanna Czenczek, 2023/06/05
[PULL 10/17] parallels: Move check of unclean image to a separate function, Hanna Czenczek, 2023/06/05
[PULL 12/17] parallels: Fix statistics calculation, Hanna Czenczek, 2023/06/05
[PULL 07/17] parallels: Fix image_end_offset and data_end after out-of-image check,
Hanna Czenczek <=
[PULL 17/17] qcow2: add discard-no-unref option, Hanna Czenczek, 2023/06/05
[PULL 15/17] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD, Hanna Czenczek, 2023/06/05
[PULL 09/17] parallels: Use generic infrastructure for BAT writing in parallels_co_check(), Hanna Czenczek, 2023/06/05
[PULL 08/17] parallels: create parallels_set_bat_entry_helper() to assign BAT value, Hanna Czenczek, 2023/06/05
[PULL 13/17] parallels: Move check of leaks to a separate function, Hanna Czenczek, 2023/06/05
[PULL 14/17] parallels: Move statistic collection to a separate function, Hanna Czenczek, 2023/06/05
[PULL 16/17] parallels: Incorrect condition in out-of-image check, Hanna Czenczek, 2023/06/05
Re: [PULL 00/17] Block patches, Richard Henderson, 2023/06/05