From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LwP8K-0002F2-Rg for qemu-devel@nongnu.org; Tue, 21 Apr 2009 19:12:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LwP8G-0002Ct-Ef for qemu-devel@nongnu.org; Tue, 21 Apr 2009 19:12:05 -0400 Received: from [199.232.76.173] (port=36419 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LwP8G-0002Cn-0X for qemu-devel@nongnu.org; Tue, 21 Apr 2009 19:12:04 -0400 Received: from savannah.gnu.org ([199.232.41.3]:43503 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LwP8F-00038L-NN for qemu-devel@nongnu.org; Tue, 21 Apr 2009 19:12:03 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LwP8F-0001Cw-7d for qemu-devel@nongnu.org; Tue, 21 Apr 2009 23:12:03 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LwP8F-0001Cq-0H for qemu-devel@nongnu.org; Tue, 21 Apr 2009 23:12:03 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Tue, 21 Apr 2009 23:12:03 +0000 Subject: [Qemu-devel] [7217] qcow2: Add plausibility check for L1/L2 entries (Kevin Wolf) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 7217 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7217 Author: aliguori Date: 2009-04-21 23:12:02 +0000 (Tue, 21 Apr 2009) Log Message: ----------- qcow2: Add plausibility check for L1/L2 entries (Kevin Wolf) From: Kevin Wolf All L1 and L2 entries must point at the start of a cluster. If there is some offset into the cluster, the entry is corrupted. Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/block-qcow2.c Modified: trunk/block-qcow2.c =================================================================== --- trunk/block-qcow2.c 2009-04-21 23:11:58 UTC (rev 7216) +++ trunk/block-qcow2.c 2009-04-21 23:12:02 UTC (rev 7217) @@ -2666,6 +2666,13 @@ errors += inc_refcounts(bs, refcount_table, refcount_table_size, offset, s->cluster_size); + + /* Correct offsets are cluster aligned */ + if (offset & (s->cluster_size - 1)) { + fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not " + "properly aligned; L2 entry corrupted.\n", offset); + errors++; + } } } } @@ -2734,6 +2741,13 @@ l2_offset, s->cluster_size); + /* L2 tables are cluster aligned */ + if (l2_offset & (s->cluster_size - 1)) { + fprintf(stderr, "ERROR l2_offset=%" PRIx64 ": Table is not " + "cluster aligned; L1 entry corrupted\n", l2_offset); + errors++; + } + /* Process and check L2 entries */ ret = check_refcounts_l2(bs, refcount_table, refcount_table_size, l2_offset, check_copied);