* [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part()
@ 2020-04-06 14:34 Alberto Garcia
2020-04-06 14:52 ` Andrey Shinkevich
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Alberto Garcia @ 2020-04-06 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy, Alberto Garcia,
qemu-block, Pavel Butsykin, Max Reitz, Andrey Shinkevich
When issuing a compressed write request the number of bytes must be a
multiple of the cluster size or reach the end of the last cluster.
With the current code such requests are allowed and we hit an
assertion:
$ qemu-img create -f qcow2 img.qcow2 1M
$ qemu-io -c 'write -c 0 32k' img.qcow2
qemu-io: block/qcow2.c:4257: qcow2_co_pwritev_compressed_task:
Assertion `bytes == s->cluster_size || (bytes < s->cluster_size &&
(offset + bytes == bs->total_sectors << BDRV_SECTOR_BITS))' failed.
Aborted
This patch fixes a regression introduced in 0d483dce38
Signed-off-by: Alberto Garcia <berto@igalia.com>
---
block/qcow2.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index 2bb536b014..587cf51948 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -4349,6 +4349,11 @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs,
return -EINVAL;
}
+ if (offset_into_cluster(s, bytes) &&
+ (offset + bytes) != (bs->total_sectors << BDRV_SECTOR_BITS)) {
+ return -EINVAL;
+ }
+
while (bytes && aio_task_pool_status(aio) == 0) {
uint64_t chunk_size = MIN(bytes, s->cluster_size);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part()
2020-04-06 14:34 [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part() Alberto Garcia
@ 2020-04-06 14:52 ` Andrey Shinkevich
2020-04-06 16:08 ` Alberto Garcia
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Andrey Shinkevich @ 2020-04-06 14:52 UTC (permalink / raw)
To: Alberto Garcia, qemu-devel@nongnu.org
Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy, qemu-block@nongnu.org,
Max Reitz
[-- Attachment #1: Type: text/plain, Size: 618 bytes --]
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
________________________________
From: Alberto Garcia <berto@igalia.com>
Sent: Monday, April 6, 2020 5:34 PM
To: qemu-devel@nongnu.org <qemu-devel@nongnu.org>
Cc: Alberto Garcia <berto@igalia.com>; qemu-block@nongnu.org <qemu-block@nongnu.org>; Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>; Max Reitz <mreitz@redhat.com>; Kevin Wolf <kwolf@redhat.com>; Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>; Pavel Butsykin <pbutsykin@virtuozzo.com>
Subject: [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part()
[-- Attachment #2: Type: text/html, Size: 1733 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part()
2020-04-06 14:34 [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part() Alberto Garcia
2020-04-06 14:52 ` Andrey Shinkevich
@ 2020-04-06 16:08 ` Alberto Garcia
2020-04-07 6:16 ` Andrey Shinkevich
2020-04-07 7:27 ` Vladimir Sementsov-Ogievskiy
2020-04-07 8:51 ` Max Reitz
3 siblings, 1 reply; 6+ messages in thread
From: Alberto Garcia @ 2020-04-06 16:08 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy, qemu-block,
Pavel Butsykin, Max Reitz, Andrey Shinkevich
I forgot to add the "for-5.0" tag in the subject, do I need to resend
the patch?
Berto
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part()
2020-04-06 16:08 ` Alberto Garcia
@ 2020-04-07 6:16 ` Andrey Shinkevich
0 siblings, 0 replies; 6+ messages in thread
From: Andrey Shinkevich @ 2020-04-07 6:16 UTC (permalink / raw)
To: Alberto Garcia, qemu-devel@nongnu.org
Cc: Kevin Wolf, Pavel Butsykin, Vladimir Sementsov-Ogievskiy,
qemu-block@nongnu.org, Max Reitz
[-- Attachment #1: Type: text/plain, Size: 648 bytes --]
I wouldn't mind either.
Andrey
________________________________
From: Alberto Garcia <berto@igalia.com>
Sent: Monday, April 6, 2020 7:08 PM
To: qemu-devel@nongnu.org <qemu-devel@nongnu.org>
Cc: qemu-block@nongnu.org <qemu-block@nongnu.org>; Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>; Max Reitz <mreitz@redhat.com>; Kevin Wolf <kwolf@redhat.com>; Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>; Pavel Butsykin <pbutsykin@virtuozzo.com>
Subject: Re: [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part()
I forgot to add the "for-5.0" tag in the subject, do I need to resend
the patch?
Berto
[-- Attachment #2: Type: text/html, Size: 1765 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part()
2020-04-06 14:34 [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part() Alberto Garcia
2020-04-06 14:52 ` Andrey Shinkevich
2020-04-06 16:08 ` Alberto Garcia
@ 2020-04-07 7:27 ` Vladimir Sementsov-Ogievskiy
2020-04-07 8:51 ` Max Reitz
3 siblings, 0 replies; 6+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2020-04-07 7:27 UTC (permalink / raw)
To: Alberto Garcia, qemu-devel
Cc: Kevin Wolf, Andrey Shinkevich, Pavel Butsykin, qemu-block,
Max Reitz
06.04.2020 17:34, Alberto Garcia wrote:
> When issuing a compressed write request the number of bytes must be a
> multiple of the cluster size or reach the end of the last cluster.
>
> With the current code such requests are allowed and we hit an
> assertion:
>
> $ qemu-img create -f qcow2 img.qcow2 1M
> $ qemu-io -c 'write -c 0 32k' img.qcow2
>
> qemu-io: block/qcow2.c:4257: qcow2_co_pwritev_compressed_task:
> Assertion `bytes == s->cluster_size || (bytes < s->cluster_size &&
> (offset + bytes == bs->total_sectors << BDRV_SECTOR_BITS))' failed.
> Aborted
>
> This patch fixes a regression introduced in 0d483dce38
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> block/qcow2.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 2bb536b014..587cf51948 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -4349,6 +4349,11 @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs,
> return -EINVAL;
> }
>
> + if (offset_into_cluster(s, bytes) &&
> + (offset + bytes) != (bs->total_sectors << BDRV_SECTOR_BITS)) {
> + return -EINVAL;
> + }
> +
> while (bytes && aio_task_pool_status(aio) == 0) {
> uint64_t chunk_size = MIN(bytes, s->cluster_size);
>
>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part()
2020-04-06 14:34 [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part() Alberto Garcia
` (2 preceding siblings ...)
2020-04-07 7:27 ` Vladimir Sementsov-Ogievskiy
@ 2020-04-07 8:51 ` Max Reitz
3 siblings, 0 replies; 6+ messages in thread
From: Max Reitz @ 2020-04-07 8:51 UTC (permalink / raw)
To: Alberto Garcia, qemu-devel
Cc: Kevin Wolf, Andrey Shinkevich, Vladimir Sementsov-Ogievskiy,
qemu-block, Pavel Butsykin
[-- Attachment #1.1: Type: text/plain, Size: 907 bytes --]
On 06.04.20 16:34, Alberto Garcia wrote:
> When issuing a compressed write request the number of bytes must be a
> multiple of the cluster size or reach the end of the last cluster.
>
> With the current code such requests are allowed and we hit an
> assertion:
>
> $ qemu-img create -f qcow2 img.qcow2 1M
> $ qemu-io -c 'write -c 0 32k' img.qcow2
>
> qemu-io: block/qcow2.c:4257: qcow2_co_pwritev_compressed_task:
> Assertion `bytes == s->cluster_size || (bytes < s->cluster_size &&
> (offset + bytes == bs->total_sectors << BDRV_SECTOR_BITS))' failed.
> Aborted
>
> This patch fixes a regression introduced in 0d483dce38
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
> block/qcow2.c | 5 +++++
> 1 file changed, 5 insertions(+)
Thanks, applied to my block branch:
https://git.xanclic.moe/XanClic/qemu/commits/branch/block
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-07 9:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-06 14:34 [PATCH v2] qcow2: Check request size in qcow2_co_pwritev_compressed_part() Alberto Garcia
2020-04-06 14:52 ` Andrey Shinkevich
2020-04-06 16:08 ` Alberto Garcia
2020-04-07 6:16 ` Andrey Shinkevich
2020-04-07 7:27 ` Vladimir Sementsov-Ogievskiy
2020-04-07 8:51 ` Max Reitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).