Skip to content

Misc qcow2 corruption checks

Alberto Garcia qemu-devel 2 versions – Applied

Status from this message: Thanks, applied to my block branch:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 10 repliesApplied
  2. v14 patches 8 repliesSuperseded

Changes in v2 from the cover letter

- Use goto fail in the l2_allocate() check [Max]
- Add check and test case for allocation of compressed clusters [Max]
- Add test case for header.refcount_table_offset == 0
- Add overlap checks to qcow2_crypto_hdr_init_func() [Max]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/7qcow2: Prevent allocating refcount blocks at offset 0block/qcow2-refcount.c tests/qemu-iotests/060 tests/qemu-iotests/060.out+26 -00 replies
2/7qcow2: Prevent allocating L2 tables at offset 0block/qcow2-cluster.c tests/qemu-iotests/060 tests/qemu-iotests/060.out+21 -00 replies
3/7qcow2: Prevent allocating compressed clusters at offset 0block/qcow2-refcount.c tests/qemu-iotests/060 tests/qemu-iotests/060.out+25 -15 replies
4/7qcow2: Don't open images with header.refcount_table_clusters == 0block/qcow2.c tests/qemu-iotests/060 tests/qemu-iotests/060.out+18 -02 replies
5/7qcow2: Add iotest for an image with header.refcount_table_offset == 0tests/qemu-iotests/060 tests/qemu-iotests/060.out+13 -01 reply
6/7qcow2: Add iotest for an empty refcount tabletests/qemu-iotests/060 tests/qemu-iotests/060.out+13 -00 replies
7/7qcow2: Assert that the crypto header does not overlap other metadatablock/qcow2.c+1 -01 reply

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchMax ReitzDaniel P. Berrange
1/7R-b
2/7R-b
3/7R-b
4/7R-b
5/7R-b
6/7R-b
7/7R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/7] Misc qcow2 corruption checks

This series contains a few checks that prevent QEMU from crashing under some scenarios with corrupted qcow2 images.

The first patch solves the crash reported here:

https://bugs.launchpad.net/qemu/+bug/1728615

And the others solve similar crashes that I detected in the process of fixing this one.

Regards,

Berto

v2:
- Use goto fail in the l2_allocate() check [Max]
- Add check and test case for allocation of compressed clusters [Max]
- Add test case for header.refcount_table_offset == 0
- Add overlap checks to qcow2_crypto_hdr_init_func() [Max]

v1: https://lists.gnu.org/archive/html/qemu-block/2017-11/msg00010.html
- Initial version

Output of backport-diff against v1:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/7:[----] [--] 'qcow2: Prevent allocating refcount blocks at offset 0' 002/7:[0003] [FC] 'qcow2: Prevent allocating L2 tables at offset 0' 003/7:[down] 'qcow2: Prevent allocating compressed clusters at offset 0' 004/7:[----] [-C] 'qcow2: Don't open images with header.refcount_table_clusters == 0' 005/7:[down] 'qcow2: Add iotest for an image with header.refcount_table_offset == 0' 006/7:[----] [--] 'qcow2: Add iotest for an empty refcount table' 007/7:[down] 'qcow2: Assert that the crypto header does not overlap other metadata'

Alberto Garcia (7):
qcow2: Prevent allocating refcount blocks at offset 0
qcow2: Prevent allocating L2 tables at offset 0
qcow2: Prevent allocating compressed clusters at offset 0
qcow2: Don't open images with header.refcount_table_clusters == 0
qcow2: Add iotest for an image with header.refcount_table_offset == 0
qcow2: Add iotest for an empty refcount table
qcow2: Assert that the crypto header does not overlap other metadata

 block/qcow2-cluster.c      |  8 ++++++++
 block/qcow2-refcount.c     | 15 +++++++++++++-
 block/qcow2.c              |  7 +++++++
 tests/qemu-iotests/060     | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/060.out | 39 ++++++++++++++++++++++++++++++++++++
 5 files changed, 117 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.0