qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	jsnow@redhat.com
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-block@nongnu.org, Juan Quintela <quintela@redhat.com>,
	libvir-list@redhat.com, Markus Armbruster <armbru@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: [PULL 01/10] hbitmap: assert that we don't create bitmap larger than INT64_MAX
Date: Tue, 17 Mar 2020 00:38:10 -0400	[thread overview]
Message-ID: <20200317043819.20197-2-jsnow@redhat.com> (raw)
In-Reply-To: <20200317043819.20197-1-jsnow@redhat.com>

From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

We have APIs which returns signed int64_t, to be able to return error.
Therefore we can't handle bitmaps with absolute size larger than
(INT64_MAX+1). Still, keep maximum to be INT64_MAX which is a bit
safer.

Note, that bitmaps are used to represent disk images, which can't
exceed INT64_MAX anyway.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-id: 20200205112041.6003-2-vsementsov@virtuozzo.com
Signed-off-by: John Snow <jsnow@redhat.com>
---
 util/hbitmap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/util/hbitmap.c b/util/hbitmap.c
index 242c6e519c..7f9b3e0cd7 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -716,6 +716,7 @@ HBitmap *hbitmap_alloc(uint64_t size, int granularity)
     HBitmap *hb = g_new0(struct HBitmap, 1);
     unsigned i;
 
+    assert(size <= INT64_MAX);
     hb->orig_size = size;
 
     assert(granularity >= 0 && granularity < 64);
@@ -746,6 +747,7 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size)
     uint64_t num_elements = size;
     uint64_t old;
 
+    assert(size <= INT64_MAX);
     hb->orig_size = size;
 
     /* Size comes in as logical elements, adjust for granularity. */
-- 
2.21.1



  reply	other threads:[~2020-03-17  4:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17  4:38 [PULL 00/10] Bitmaps patches John Snow
2020-03-17  4:38 ` John Snow [this message]
2020-03-17  4:38 ` [PULL 02/10] hbitmap: move hbitmap_iter_next_word to hbitmap.c John Snow
2020-03-17  4:38 ` [PULL 03/10] hbitmap: unpublish hbitmap_iter_skip_words John Snow
2020-03-17  4:38 ` [PULL 04/10] hbitmap: drop meta bitmaps as they are unused John Snow
2020-03-17  4:38 ` [PULL 05/10] block/dirty-bitmap: switch _next_dirty_area and _next_zero to int64_t John Snow
2020-03-17  4:38 ` [PULL 06/10] block/dirty-bitmap: add _next_dirty API John Snow
2020-03-17  4:38 ` [PULL 07/10] block/dirty-bitmap: improve _next_dirty_area API John Snow
2020-03-17  4:38 ` [PULL 08/10] nbd/server: introduce NBDExtentArray John Snow
2020-03-17  4:38 ` [PULL 09/10] nbd/server: use bdrv_dirty_bitmap_next_dirty_area John Snow
2020-03-17  4:38 ` [PULL 10/10] block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty John Snow
2020-03-17 14:00 ` [PULL 00/10] Bitmaps patches Peter Maydell
2020-03-17 14:40   ` Eric Blake
2020-03-17 14:57     ` Daniel P. Berrangé
2020-03-17 15:00       ` Peter Maydell
2020-03-17 15:05         ` Daniel P. Berrangé
2020-03-17 15:07           ` Peter Maydell
2020-03-17 15:11             ` Daniel P. Berrangé
2020-03-17 15:49               ` Eric Blake
2020-03-18 12:47   ` Eric Blake

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=20200317043819.20197-2-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.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).