From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
mreitz@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] qed: check for header size overflow
Date: Mon, 12 Jan 2015 12:31:32 +0000 [thread overview]
Message-ID: <1421065893-18875-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1421065893-18875-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>
---
block/qed.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/block/qed.c b/block/qed.c
index 80f18d8..d2c6045 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -440,6 +440,12 @@ 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 ((uint64_t)s->header.cluster_size * s->header.header_size !=
+ s->header.cluster_size * s->header.header_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
next prev parent reply other threads:[~2015-01-12 12:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-12 12:31 [Qemu-devel] [PATCH 0/2] qed: additional input validation Stefan Hajnoczi
2015-01-12 12:31 ` Stefan Hajnoczi [this message]
2015-01-14 14:00 ` [Qemu-devel] [PATCH 1/2] qed: check for header size overflow Kevin Wolf
2015-01-12 12:31 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: add 116 invalid QED input file tests Stefan Hajnoczi
2015-01-15 15:23 ` [Qemu-devel] [PATCH 0/2] qed: additional input validation 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=1421065893-18875-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--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).