qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: Klim Kireev <sproff@linux.com>,
	Klim Kireev <proffk@virtuozzo.mipt.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/1] block/parallels: check new image size
Date: Wed, 27 Jul 2016 19:05:09 +0200	[thread overview]
Message-ID: <5798E9C5.7040307@openvz.org> (raw)
In-Reply-To: <1469638872-12064-1-git-send-email-den@openvz.org>

On 07/27/2016 07:01 PM, Denis V. Lunev wrote:
> From: Klim Kireev <sproff@linux.com>
>
> Before this patch incorrect image could be created via qemu-img
> (Example: qemu-img create -f parallels -o size=4096T hack.img),
> incorrect images cannot be used due to overflow in main image structure.
>
> This patch add check of size in image creation.
>
> After reading size it compare it with UINT32_MAX * cluster_size.
>
> Signed-off-by: Klim Kireev <proffk@virtuozzo.mipt.com>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>   block/parallels.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/block/parallels.c b/block/parallels.c
> index 807a801..a0bc95b 100644
> --- a/block/parallels.c
> +++ b/block/parallels.c
> @@ -43,6 +43,7 @@
>   #define HEADER_MAGIC2 "WithouFreSpacExt"
>   #define HEADER_VERSION 2
>   #define HEADER_INUSE_MAGIC  (0x746F6E59)
> +#define MAX_PARALLELS_IMAGE_FACTOR (1ull << 32)
>   
>   #define DEFAULT_CLUSTER_SIZE 1048576        /* 1 MiB */
>   
> @@ -475,6 +476,10 @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp)
>                             BDRV_SECTOR_SIZE);
>       cl_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE,
>                             DEFAULT_CLUSTER_SIZE), BDRV_SECTOR_SIZE);
> +    if (total_size >= MAX_PARALLELS_IMAGE_FACTOR * cl_size) {
> +        error_propagate(errp, local_err);
> +        return -E2BIG;
> +    }
>   
>       ret = bdrv_create_file(filename, opts, &local_err);
>       if (ret < 0) {
pls drop this. I have to resubmit it.

      reply	other threads:[~2016-07-27 18:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-27 17:01 [Qemu-devel] [PATCH 1/1] block/parallels: check new image size Denis V. Lunev
2016-07-27 17:05 ` Denis V. Lunev [this message]

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=5798E9C5.7040307@openvz.org \
    --to=den@openvz.org \
    --cc=proffk@virtuozzo.mipt.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sproff@linux.com \
    --cc=stefanha@redhat.com \
    /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).