[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-upstream-unstable] qcow2: fix possible corruption when reading multiple clusters



commit 4d2f39a918ab4ccac7255da143b4322a9b4b204a
Author:     Peter Lieven <pl@xxxxxxx>
AuthorDate: Tue Nov 12 13:48:07 2013 +0100
Commit:     Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
CommitDate: Mon Dec 9 11:40:30 2013 -0600

    qcow2: fix possible corruption when reading multiple clusters
    
    if multiple sectors spanning multiple clusters are read the
    function count_contiguous_clusters should ensure that the
    cluster type should not change between the clusters.
    
    Especially the for-loop should break when we have one
    or more normal clusters followed by a compressed cluster.
    
    Unfortunately the wrong macro was used in the mask to
    compare the flags.
    
    This was discovered while debugging a data corruption
    issue when converting a compressed qcow2 image to raw.
    qemu-img reads 2MB chunks which span multiple clusters.
    
    CC: qemu-stable@xxxxxxxxxx
    Signed-off-by: Peter Lieven <pl@xxxxxxx>
    Signed-off-by: Kevin Wolf <kwolf@xxxxxxxxxx>
    (cherry picked from commit 78a52ad5acca7053b774fcc80290e7b7e224c80a)
    
    Signed-off-by: Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
---
 block/qcow2-cluster.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index fd3054b..b558eb0 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -266,7 +266,7 @@ static int count_contiguous_clusters(uint64_t nb_clusters, 
int cluster_size,
         uint64_t *l2_table, uint64_t start, uint64_t stop_flags)
 {
     int i;
-    uint64_t mask = stop_flags | L2E_OFFSET_MASK | QCOW2_CLUSTER_COMPRESSED;
+    uint64_t mask = stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED;
     uint64_t first_entry = be64_to_cpu(l2_table[0]);
     uint64_t offset = first_entry & mask;
 
--
generated by git-patchbot for /home/xen/git/qemu-upstream-unstable.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.