From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDx8b-0000R3-1F for qemu-devel@nongnu.org; Wed, 21 Jan 2015 10:24:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDx8X-00064o-NK for qemu-devel@nongnu.org; Wed, 21 Jan 2015 10:24:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDx8X-00064H-Gr for qemu-devel@nongnu.org; Wed, 21 Jan 2015 10:24:05 -0500 Date: Wed, 21 Jan 2015 15:23:53 +0000 From: Stefan Hajnoczi Message-ID: <20150121152353.GC4740@stefanha-thinkpad.redhat.com> References: <1416844620-17717-1-git-send-email-mreitz@redhat.com> <1416844620-17717-12-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="E13BgyNx05feLLmH" Content-Disposition: inline In-Reply-To: <1416844620-17717-12-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 11/12] qcow2/overlaps: Protect inactive L2 tables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , Peter Lieven , qemu-devel@nongnu.org --E13BgyNx05feLLmH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 24, 2014 at 04:56:59PM +0100, Max Reitz wrote: > @@ -136,6 +138,34 @@ int qcow2_read_snapshots(BlockDriverState *bs) > size_to_clusters(s, sn->l1_size * > sizeof(uint64_t)), > QCOW2_OL_INACTIVE_L1); > + > + if (!(s->overlap_check & QCOW2_OL_INACTIVE_L2)) { > + continue; > + } > + > + l1_table = qemu_try_blockalign(bs->file, > + sn->l1_size * sizeof(uint64_t)); At this point we haven't validated sn->l1_size <= QCOW_MAX_L1_SIZE. A bogus l1_size means we do a huge read and add junk into the metadata list. I think it would be best to check the value here. --E13BgyNx05feLLmH Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUv8SJAAoJEJykq7OBq3PIM6EH/RaP97968yu+2+V9hLH4+Uba wyjhoS9pWMEhWnY3+lrpCFtn8UZqRwcuV7IFECdxpBl4WfM5+rugBSYV9K7g7XD4 wJLsp7pK3iGnHaoqqv3vM0Kyh7/a8eohR9yuVcITGra074DbNqQbhpCNh7fhj5vq w7gGssAs8u49isAYAL8ovzPbyU4+ZzHgbY9uHUQd6vNoTEjy3XUsCVQ14bC/Y6Ta VY0X4Ax0hznB+3FCv2U+Yw3gR8+LKqehb3O8RSlGNU8azyI109ElHs+oZvMnXakr r0IhGs3126p7QAr4dvNx2on7Lc0h+y7EvpuAFFKezrtczDwQZv88gRY9H0c5UF4= =LUZV -----END PGP SIGNATURE----- --E13BgyNx05feLLmH--