Kevin Wolf 176d3f3351 qcow2: Don't rely on free_cluster_index in alloc_refcount_block() (CVE-2014-0147)
free_cluster_index is only correct if update_refcount() was called from
an allocation function, and even there it's brittle because it's used to
protect unfinished allocations which still have a refcount of 0 - if it
moves in the wrong place, the unfinished allocation can be corrupted.

So not using it any more seems to be a good idea. Instead, use the
first requested cluster to do the calculations. Return -EAGAIN if
unfinished allocations could become invalid and let the caller restart
its search for some free clusters.

The context of creating a snapsnot is one situation where
update_refcount() is called outside of a cluster allocation. For this
case, the change fixes a buffer overflow if a cluster is referenced in
an L2 table that cannot be represented by an existing refcount block.
(new_table[refcount_table_index] was out of bounds)

[Bump the qemu-iotests 026 refblock_alloc.write leak count from 10 to
11.
--Stefan]

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit b106ad9185)
[AF: BNC#870439; dropped QCOW2_DISCARD_NEVER argument to
     qcow2_free_clusters() and update_refcount(), dropped iotests]
Signed-off-by: Andreas Färber <afaerber@suse.de>
2015-02-05 08:18:41 -07:00
2013-01-26 13:15:35 +00:00
2012-12-19 08:29:06 +01:00
2013-01-18 19:06:57 +01:00
2012-10-24 10:26:22 +02:00
2013-02-01 15:53:11 -06:00
2013-04-02 16:34:06 -05:00
2013-01-30 16:03:57 +00:00
2013-02-06 15:52:07 +01:00
2013-02-13 11:56:02 -06:00
2015-02-05 08:18:37 -07:00
2012-09-07 09:02:44 +03:00
2015-02-05 08:18:37 -07:00
2012-11-01 13:10:06 +01:00
2013-06-12 16:23:07 +02:00
2012-05-14 07:27:24 +02:00
2012-12-20 23:08:47 +01:00
2013-01-30 10:42:29 +01:00
2013-01-26 13:15:35 +00:00
2012-12-20 23:09:25 +01:00
2013-01-17 10:24:52 -02:00
2013-06-12 16:23:04 +02:00
2013-04-02 15:44:43 -05:00
2013-07-25 15:42:10 +02:00
2013-02-11 13:22:39 -06:00
2013-05-23 17:12:44 -05:00
2013-01-15 04:09:14 +01:00

Read the documentation in qemu-doc.html or on http://wiki.qemu.org

- QEMU team
S
Description
Languages
C 82.6%
C++ 6.5%
Python 3.3%
Dylan 2.9%
Shell 1.6%
Other 2.9%