]> git.ipfire.org Git - thirdparty/qemu.git/commit
qcow2: Fix theoretical corruption in store_bitmap() error path
authorKevin Wolf <kwolf@redhat.com>
Thu, 12 Jan 2023 19:14:51 +0000 (20:14 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 29 Mar 2023 07:20:04 +0000 (10:20 +0300)
commit6e0c9109046d4cec3d1c277f4bf54602c3fc1ba6
treef1bec4b7df527cf9c7692d29cae1eea0d5ba1e9f
parenteca533b60a44796143133eeb30fe61a8c9d429e9
qcow2: Fix theoretical corruption in store_bitmap() error path

In order to write the bitmap table to the image file, it is converted to
big endian. If the write fails, it is passed to clear_bitmap_table() to
free all of the clusters it had allocated before. However, if we don't
convert it back to native endianness first, we'll free things at a wrong
offset.

In practical terms, the offsets will be so high that we won't actually
free any allocated clusters, but just run into an error, but in theory
this can cause image corruption.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230112191454.169353-2-kwolf@redhat.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit b03dd9613bcf8fe948581b2b3585510cb525c382)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
block/qcow2-bitmap.c