From: Eric Blake <eblake@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 4/4] qcow2: Avoid memory over-allocation on compressed images
Date: Thu, 22 Feb 2018 13:02:44 -0600 [thread overview]
Message-ID: <46083cc3-08b8-89ef-2b71-a6ecb9bbb594@redhat.com> (raw)
In-Reply-To: <w51371t56ys.fsf@maestria.local.igalia.com>
On 02/22/2018 10:23 AM, Alberto Garcia wrote:
> On Thu 22 Feb 2018 04:59:22 PM CET, Eric Blake wrote:
>> sector_offset = coffset & 511;
>> csize = nb_csectors * 512 - sector_offset;
> [...]
>> + assert(csize < 2 * s->cluster_size);
>
> I think it should be <=
>
> If sector_offset is 0 and nb_csector is the maximum allowed value then
> csize is exactly 2 * s->cluster_size bytes.
Sigh, yes you're right. I was thinking that "qemu sets csize to a
maximum of s->cluster_size, but only when sector_offset is not 0" - but
as long as we're dealing with externally-produced images, sector_offset
can be 0 at the same time as providing all 1s to the field. So I did
indeed have an off-by-one.
Perhaps the maintainer can fix it up, instead of me spinning a v4?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2018-02-22 19:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-22 15:59 [Qemu-devel] [PATCH v3 0/4] qcow2: minor compression improvements Eric Blake
2018-02-22 15:59 ` [Qemu-devel] [PATCH v3 1/4] qcow2: Prefer byte-based calls into bs->file Eric Blake
2018-02-22 15:59 ` [Qemu-devel] [PATCH v3 2/4] qcow2: Document some maximum size constraints Eric Blake
2018-02-26 16:25 ` Alberto Garcia
2018-02-26 16:41 ` Eric Blake
2018-02-26 16:46 ` Alberto Garcia
2018-02-27 11:47 ` Kevin Wolf
2018-02-27 14:31 ` Eric Blake
2018-02-27 14:41 ` Alberto Garcia
2018-02-22 15:59 ` [Qemu-devel] [PATCH v3 3/4] qcow2: Don't allow overflow during cluster allocation Eric Blake
2018-02-26 16:29 ` Alberto Garcia
2018-02-22 15:59 ` [Qemu-devel] [PATCH v3 4/4] qcow2: Avoid memory over-allocation on compressed images Eric Blake
2018-02-22 16:23 ` Alberto Garcia
2018-02-22 19:02 ` Eric Blake [this message]
2018-02-26 16:35 ` Alberto Garcia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46083cc3-08b8-89ef-2b71-a6ecb9bbb594@redhat.com \
--to=eblake@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).