From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnrHN-00031Y-EI for qemu-devel@nongnu.org; Fri, 23 May 2014 11:21:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WnrHH-00055P-49 for qemu-devel@nongnu.org; Fri, 23 May 2014 11:21:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnrHG-000559-RM for qemu-devel@nongnu.org; Fri, 23 May 2014 11:20:59 -0400 Date: Fri, 23 May 2014 17:20:54 +0200 From: Stefan Hajnoczi Message-ID: <20140523152054.GB4585@stefanha-thinkpad.redhat.com> References: <1400852489-31099-1-git-send-email-maria.k@catit.be> <537F5380.8090807@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <537F5380.8090807@redhat.com> Subject: Re: [Qemu-devel] [PATCH] docs: Define refcount_bits value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, Maria Kustova , qemu-devel@nongnu.org, Maria Kustova On Fri, May 23, 2014 at 07:56:16AM -0600, Eric Blake wrote: > On 05/23/2014 07:41 AM, Maria Kustova wrote: > > > 96 - 99: refcount_order > > Describes the width of a reference count block entry (width > > - in bits = 1 << refcount_order). For version 2 images, the > > - order is always assumed to be 4 (i.e. the width is 16 bits). > > + in bits: refcount_bits = 1 << refcount_order). For version 2 > > + images, the order is always assumed to be 4 > > + (i.e. refcount_bits = 16). > > In light of all the recent CVE fixes (and possibly a separate patch if > any code is broken), I wonder if we need more work to ensure that > refcount_order is capped to a worthwhile maximum rather than causing > undefined behavior. That is, a refcount_order of 0x10004 should be an > error, and not a synonym of refcount_order of 4, since '1 << 0x10004' is > undefined. > > Furthermore, this raises some questions in my mind. Later on, we document: > > refcount_block_entries = (cluster_size / sizeof(uint16_t)) > > which implies a hard cap of refcount_bits=16 as the maximum, which in > turn implies a hard cap of refcount_order of 4 as the maximum. Or is it > possible to specify a larger refcount_order, in which case > refcount_block_entries is dynamically sized to uint32_t, and in which > case the rest of the docs need to be fixed to accommodate that? > > Also, > > Refcount block entry (x = refcount_bits - 1): > > Bit 0 - x: Reference count of the cluster. If refcount_bits > implies a > sub-byte width, note that bit 0 means the least > significant > bit in this context. > > but nothing is said about bits x+1 - 15 (which only exist when > refcount_order < 4, but which presumably must be all 0 bits for the file > to be valid). Only refcount_order = 4 is supported by QEMU at the moment. I agree the spec could be made a bit clearer though. Maybe Kevin wants to send a patch to explain the details of refcount entry sizing. Stefan