From 93bbaf03ff7fd490e823814b8f5d6849a7b71a64 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Fri, 10 Nov 2017 21:31:08 +0100 Subject: qcow2: Unaligned zero cluster in handle_alloc() We should check whether the cluster offset we are about to use is actually valid; that is, whether it is aligned to cluster boundaries. Reported-by: R. Nageswara Sastry Buglink: https://bugs.launchpad.net/qemu/+bug/1728643 Buglink: https://bugs.launchpad.net/qemu/+bug/1728657 Signed-off-by: Max Reitz Message-id: 20171110203111.7666-3-mreitz@redhat.com Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia Signed-off-by: Max Reitz --- tests/qemu-iotests/060 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/qemu-iotests/060') diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 index 56bdf1e..49bc89d 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -321,6 +321,22 @@ echo '--- Repairing ---' # because the image was already marked corrupt by that point _check_test_img -r all +echo +echo "=== Writing to an unaligned preallocated zero cluster ===" +echo + +_make_test_img 64M + +# Allocate the L2 table +$QEMU_IO -c "write 0 64k" -c "discard 0 64k" "$TEST_IMG" | _filter_qemu_io +# Pretend there is a preallocated zero cluster somewhere inside the +# image header +poke_file "$TEST_IMG" "$l2_offset" "\x80\x00\x00\x00\x00\x00\x2a\x01" +# Let's write to it! +$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io + +# Can't repair this yet (TODO: We can just deallocate the cluster) + # success, all done echo "*** done" rm -f $seq.full -- cgit v1.1