qemu/block
Anthony Liguori 79368c81bf Make default invocation of block drivers safer (v3)
CVE-2008-2004 described a vulnerability in QEMU whereas a malicious user could
trick the block probing code into accessing arbitrary files in a guest.  To
mitigate this, we added an explicit format parameter to -drive which disabling
block probing.

Fast forward to today, and the vast majority of users do not use this parameter.
libvirt does not use this by default nor does virt-manager.

Most users want block probing so we should try to make it safer.

This patch adds some logic to the raw device which attempts to detect a write
operation to the beginning of a raw device.  If the first 4 bytes happen to
match an image file that has a backing file that we support, it scrubs the
signature to all zeros.  If a user specifies an explicit format parameter, this
behavior is disabled.

I contend that while a legitimate guest could write such a signature to the
header, we would behave incorrectly anyway upon the next invocation of QEMU.
This simply changes the incorrect behavior to not involve a security
vulnerability.

I've tested this pretty extensively both in the positive and negative case.  I'm
not 100% confident in the block layer's ability to deal with zero sized writes
particularly with respect to the aio functions so some additional eyes would be
appreciated.

Even in the case of a single sector write, we have to make sure to invoked the
completion from a bottom half so just removing the zero sized write is not an
option.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-07-15 08:17:06 -05:00
..
blkdebug.c blkdebug: Initialize state as 1 2010-07-02 13:18:02 +02:00
bochs.c bochs: use qemu block API 2010-05-17 10:20:05 +02:00
cloop.c cloop: use qemu block API 2010-05-17 10:20:04 +02:00
cow.c cow: Use bdrv_(p)write_sync for metadata writes 2010-06-22 14:38:02 +02:00
curl.c Fix %lld or %llx printf format use 2010-05-22 08:02:12 +00:00
dmg.c dmg: use qemu block API 2010-05-17 10:20:05 +02:00
nbd.c block: Open the underlying image file in generic code 2010-05-03 10:07:30 +02:00
parallels.c parallels: use qemu block API 2010-05-17 10:20:05 +02:00
qcow2-cluster.c qcow2: Use bdrv_(p)write_sync for metadata writes 2010-06-22 14:38:02 +02:00
qcow2-refcount.c qcow2/vdi: Change check to distinguish error cases 2010-07-06 17:05:49 +02:00
qcow2-snapshot.c qcow2: Use bdrv_(p)write_sync for metadata writes 2010-06-22 14:38:02 +02:00
qcow2.c qcow2/vdi: Change check to distinguish error cases 2010-07-06 17:05:49 +02:00
qcow2.h qcow2/vdi: Change check to distinguish error cases 2010-07-06 17:05:49 +02:00
qcow.c qcow: Use bdrv_(p)write_sync for metadata writes 2010-06-22 14:38:02 +02:00
raw-posix-aio.h Remove aio_ctx from paio_* interface 2009-10-30 08:39:34 -05:00
raw-posix.c raw-posix: Fix test for host CD-ROM 2010-07-06 17:05:49 +02:00
raw-win32.c block: Open the underlying image file in generic code 2010-05-03 10:07:30 +02:00
raw.c Make default invocation of block drivers safer (v3) 2010-07-15 08:17:06 -05:00
sheepdog.c sheepdog: fix compile error on systems without TCP_CORK 2010-07-07 20:54:56 +03:00
vdi.c qcow2/vdi: Change check to distinguish error cases 2010-07-06 17:05:49 +02:00
vmdk.c vmdk: Use bdrv_(p)write_sync for metadata writes 2010-06-22 14:38:02 +02:00
vpc.c vpc: Use bdrv_(p)write_sync for metadata writes 2010-06-22 14:38:02 +02:00
vvfat.c vvfat: More build fixes with DEBUG 2010-05-21 11:49:19 +02:00