qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Cc: benoit.canet@irqsave.net, qemu-stable@nongnu.org,
	stefanha@redhat.com, ppandit@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/5] qcow1: Make padding in the header explicit
Date: Thu, 15 May 2014 09:49:43 -0600	[thread overview]
Message-ID: <5374E217.7090607@redhat.com> (raw)
In-Reply-To: <1400163717-1898-2-git-send-email-kwolf@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

On 05/15/2014 08:21 AM, Kevin Wolf wrote:
> We were relying on all compilers inserting the same padding in the
> header struct that is used for the on-disk format. Let's not do that.
> Mark the struct as packed and insert an explicit padding field for
> compatibility.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Benoit Canet <benoit@irqsave.net>
> ---
>  block/qcow.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/qcow.c b/block/qcow.c
> index 937dd6d..3684794 100644
> --- a/block/qcow.c
> +++ b/block/qcow.c
> @@ -48,9 +48,10 @@ typedef struct QCowHeader {
>      uint64_t size; /* in bytes */
>      uint8_t cluster_bits;
>      uint8_t l2_bits;
> +    uint16_t padding;
>      uint32_t crypt_method;
>      uint64_t l1_table_offset;
> -} QCowHeader;
> +} QEMU_PACKED QCowHeader;

Is it worth a compile-time assertion that the correct size is achieved?

[I don't know if glib provides such a macro, but gnulib has a verify()
macro that could be used as:

verify(sizeof(QCowHeader) == NNN)

which expands to _Static_assert(sizeof(QCowHeader) == NNN) in new enough
C compilers, and to something like

extern int (*dummy1(void)) [sizeof (struct dummy2 {
  int dummy3: (sizeof(QCowHeader) == NNN) ? 1 : -1; })]

on older compilers for reliable compile-time detection]

But not a show-stopper to this patch as-is.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-05-15 15:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 14:21 [Qemu-devel] [PATCH v2 0/5] qcow1: Input validation fixes Kevin Wolf
2014-05-15 14:21 ` [Qemu-devel] [PATCH v2 1/5] qcow1: Make padding in the header explicit Kevin Wolf
2014-05-15 15:49   ` Eric Blake [this message]
2014-05-16 10:41     ` Kevin Wolf
2014-05-16 12:42       ` Eric Blake
2014-05-15 14:21 ` [Qemu-devel] [PATCH v2 2/5] qcow1: Check maximum cluster size Kevin Wolf
2014-05-15 16:34   ` Benoît Canet
2014-05-15 14:21 ` [Qemu-devel] [PATCH v2 3/5] qcow1: Validate L2 table size (CVE-2014-0222) Kevin Wolf
2014-05-15 16:34   ` Benoît Canet
2014-05-15 14:21 ` [Qemu-devel] [PATCH v2 4/5] qcow1: Validate image size (CVE-2014-0223) Kevin Wolf
2014-05-15 16:35   ` Benoît Canet
2014-05-16 10:47     ` Kevin Wolf
2014-05-16 11:22       ` Benoît Canet
2014-05-15 14:21 ` [Qemu-devel] [PATCH v2 5/5] qcow1: Stricter backing file length check Kevin Wolf

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=5374E217.7090607@redhat.com \
    --to=eblake@redhat.com \
    --cc=benoit.canet@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --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).