qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 14/16] qed: check for header size overflow
Date: Fri, 16 Jan 2015 15:37:11 +0000	[thread overview]
Message-ID: <1421422633-25536-15-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1421422633-25536-1-git-send-email-stefanha@redhat.com>

Header size is denoted in clusters.  The maximum cluster size is 64 MB
but there is no limit on header size.  Check for uint32_t overflow in
case the header size field has a whacky value.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1421065893-18875-2-git-send-email-stefanha@redhat.com
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qed.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/block/qed.c b/block/qed.c
index 80f18d8..892b13c 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -440,6 +440,11 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
     s->l2_mask = s->table_nelems - 1;
     s->l1_shift = s->l2_shift + ffs(s->table_nelems) - 1;
 
+    /* Header size calculation must not overflow uint32_t */
+    if (s->header.header_size > UINT32_MAX / s->header.cluster_size) {
+        return -EINVAL;
+    }
+
     if ((s->header.features & QED_F_BACKING_FILE)) {
         if ((uint64_t)s->header.backing_filename_offset +
             s->header.backing_filename_size >
-- 
2.1.0

  parent reply	other threads:[~2015-01-16 15:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-16 15:36 [Qemu-devel] [PULL 00/16] Block patches Stefan Hajnoczi
2015-01-16 15:36 ` [Qemu-devel] [PULL 01/16] block: add event when disk usage exceeds threshold Stefan Hajnoczi
2015-01-16 15:36 ` [Qemu-devel] [PULL 02/16] block/dmg: properly detect the UDIF trailer Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 03/16] block/dmg: extract mish block decoding functionality Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 04/16] block/dmg: extract processing of resource forks Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 05/16] block/dmg: process a buffer instead of reading ints Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 06/16] block/dmg: validate chunk size to avoid overflow Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 07/16] block/dmg: process XML plists Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 08/16] block/dmg: set virtual size to a non-zero value Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 09/16] block/dmg: fix sector data offset calculation Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 10/16] block/dmg: use SectorNumber from BLKX header Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 11/16] block/dmg: factor out block type check Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 12/16] block/dmg: support bzip2 block entry types Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 13/16] block/dmg: improve zeroes handling Stefan Hajnoczi
2015-01-16 15:37 ` Stefan Hajnoczi [this message]
2015-01-16 15:37 ` [Qemu-devel] [PULL 15/16] qemu-iotests: add 116 invalid QED input file tests Stefan Hajnoczi
2015-01-16 15:37 ` [Qemu-devel] [PULL 16/16] qemu-iotests: Fix supported_oses check Stefan Hajnoczi
2015-01-16 16:46 ` [Qemu-devel] [PULL 00/16] Block patches Peter Maydell
2015-01-17 10:41   ` Peter Wu
2015-01-20 10:26     ` Stefan Hajnoczi

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=1421422633-25536-15-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=peter.maydell@linaro.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).