From: Kevin Wolf <kwolf@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: [Qemu-devel] Re: [PATCH] Make default invocation of block drivers safer
Date: Wed, 14 Jul 2010 18:42:11 +0200 [thread overview]
Message-ID: <4C3DE8E3.8080709@redhat.com> (raw)
In-Reply-To: <1279123952-1576-1-git-send-email-aliguori@us.ibm.com>
Am 14.07.2010 18:12, schrieb Anthony Liguori:
> 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>
I guess something like this makes sense, and the approach looks okay in
general. With the check that we have really probed the format, we still
allow legitimate use cases (whatever they might be).
However, I wonder why you even bother with adjusting buffers and
requests and stuff instead of just returning a straight -EIO. Doing so
would have the additional advantage that the expectation of the guest OS
matches what is really on the disk (garbage) instead of silently
corrupting things.
> static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs,
> int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
> BlockDriverCompletionFunc *cb, void *opaque)
> {
> + if (check_write_unsafe(bs, sector_num, qiov->iov[0].iov_base, nb_sectors)) {
Have you checked that the bad value is always in iov[0]? Could a guest
construct a zero-length iov[0] and do the bad access in iov[1]? Or use
two two-byte buffers to write the magic number?
I'm not saying that any of these work, I honestly don't know, but did
you consider them?
Kevin
next prev parent reply other threads:[~2010-07-14 16:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-14 16:12 [Qemu-devel] [PATCH] Make default invocation of block drivers safer Anthony Liguori
2010-07-14 16:42 ` Kevin Wolf [this message]
2010-07-14 17:40 ` [Qemu-devel] " Anthony Liguori
2010-07-15 8:00 ` Kevin Wolf
2010-07-14 18:43 ` [Qemu-devel] " Christoph Hellwig
2010-07-14 18:50 ` Anthony Liguori
2010-07-15 9:20 ` Daniel P. Berrange
2010-07-15 12:35 ` Anthony Liguori
2010-07-15 15:19 ` Markus Armbruster
2010-07-15 16:20 ` Anthony Liguori
2010-07-15 17:10 ` Kevin Wolf
2010-07-15 17:51 ` Anthony Liguori
2010-07-16 7:30 ` Kevin Wolf
2010-07-16 12:55 ` Stefan Hajnoczi
2010-07-16 13:00 ` Stefan Hajnoczi
2010-07-16 16:06 ` Markus Armbruster
2010-07-16 16:16 ` Anthony Liguori
2010-07-16 16:24 ` Kevin Wolf
2010-07-14 18:53 ` Anthony Liguori
2010-07-14 18:54 ` Aurelien Jarno
2010-07-14 19:04 ` Anthony Liguori
2010-07-15 8:09 ` Kevin Wolf
2010-07-15 9:10 ` Stefan Hajnoczi
2010-07-15 12:57 ` Anthony Liguori
2010-07-15 13:16 ` Kevin Wolf
2010-07-15 13:20 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C3DE8E3.8080709@redhat.com \
--to=kwolf@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.