From nobody Sun Feb 8 17:21:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584419927; cv=none; d=zohomail.com; s=zohoarc; b=d/a/h99gNb6v87XMPLGG4N/iRcIMSrJ1TCIQDMi9TjCUn2qHhk6/QrQ0bAkrLayDGgum5yrmTM0VAgU8kIN5UZY80dLGwY6XC2YOEzCtiWvhL3Tmsdh5nK1vlv79bCRf+dgRhs6Gr5LjkwKEUeghZ27GBPMW5+5ldqHV+MWMpuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584419927; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ahENl3BNbjiX9217T8D2HNUwmfnYsYvdtYYCuVYsDWw=; b=LJZsgJStma+BB3q1lhvvEWsVWou+vWUwBZ1V1uhK3KHgwQau5F/EyoAiyYreazDxlW5d1e5/mHK6cXxNatTWqrmJM74fSF+rHZdgSsMjxnA/Lc52Yo7zQhYW9NlaKkIZWGyegWQgQfBuAya7B+NVl0F5EPw7IWPGLRYHoZ3763M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1584419926999193.427280825151; Mon, 16 Mar 2020 21:38:46 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-280-pUWqR0HQOpCQIrsTy68kfQ-1; Tue, 17 Mar 2020 00:38:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AAFC98017CC; Tue, 17 Mar 2020 04:38:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0EE7B10027A3; Tue, 17 Mar 2020 04:38:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B419286FED; Tue, 17 Mar 2020 04:38:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02H4cTkC012302 for ; Tue, 17 Mar 2020 00:38:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C97210027B0; Tue, 17 Mar 2020 04:38:29 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AE151036D00; Tue, 17 Mar 2020 04:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584419925; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ahENl3BNbjiX9217T8D2HNUwmfnYsYvdtYYCuVYsDWw=; b=VwBjvfVNtjcFFOtx8tJD3PPmrPJpC5S7zHIyIk/ikxdCoePB1qyw31Ej3YWX7kT/jEQpz2 QI+1b/CqvpIwWervcYTWss644mB0sv7mug8Z05TTe4GuN0PZy994YSK+NNBE7FK95lzU4D kHshQoQu+/15t7tss2EbsksaNeZ8Qcg= X-MC-Unique: pUWqR0HQOpCQIrsTy68kfQ-1 From: John Snow To: qemu-devel@nongnu.org, Peter Maydell , jsnow@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 Message-Id: <20200317043819.20197-2-jsnow@redhat.com> In-Reply-To: <20200317043819.20197-1-jsnow@redhat.com> References: <20200317043819.20197-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Juan Quintela , libvir-list@redhat.com, "Dr. David Alan Gilbert" , Stefan Hajnoczi , Max Reitz X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Reviewed-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: John Snow Message-id: 20200205112041.6003-2-vsementsov@virtuozzo.com Signed-off-by: John Snow --- 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 =3D g_new0(struct HBitmap, 1); unsigned i; =20 + assert(size <=3D INT64_MAX); hb->orig_size =3D size; =20 assert(granularity >=3D 0 && granularity < 64); @@ -746,6 +747,7 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size) uint64_t num_elements =3D size; uint64_t old; =20 + assert(size <=3D INT64_MAX); hb->orig_size =3D size; =20 /* Size comes in as logical elements, adjust for granularity. */ --=20 2.21.1