mirror of
https://github.com/qemu/qemu.git
synced 2025-08-20 16:35:15 +00:00

qcow2_refresh_limits() assumes that s->crypto is non-NULL whenever bs->encrypted is true. This is actually not the case: qcow2_do_open() allows to open an image with a missing crypto header for BDRV_O_NO_IO, and then bs->encrypted is true, but s->crypto is still NULL. It doesn't make sense to open an invalid image, so remove the exception for BDRV_O_NO_IO. This catches the problem early and any code that makes the same assumption is safe now. At the same time, in the name of defensive programming, we shouldn't make the assumption in the first place. Let qcow2_refresh_limits() check s->crypto rather than bs->encrypted. If s->crypto is NULL, it also can't make any requirement on request alignment. Finally, start a qcow2-encryption test case that only serves as a regression test for this crash for now. Reported-by: Leonid Reviakin <L.reviakin@fobos-nt.ru> Reported-by: Denis Rastyogin <gerben@altlinux.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20250318201143.70657-1-kwolf@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
=== This is the QEMU I/O test suite === * Intro This package contains a simple test suite for the I/O layer of qemu. It does not require a guest, but only the qemu, qemu-img and qemu-io binaries. This does limit it to exercise the low-level I/O path only but no actual block drivers like ide, scsi or virtio. * Usage Just run ./check to run all tests for the raw image format, or ./check -qcow2 to test the qcow2 image format. The output of ./check -h explains additional options to test further image formats or I/O methods. * Feedback and patches Please send improvements to the test suite, general feedback or just reports of failing tests cases to qemu-devel@nongnu.org with a CC: to qemu-block@nongnu.org.