qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Cc: jcody@redhat.com, Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC 2/2] block: Warn on insecure format probing
Date: Mon, 03 Nov 2014 16:13:02 +0100	[thread overview]
Message-ID: <54579B7E.4000605@redhat.com> (raw)
In-Reply-To: <20141103150533.GC4609@stefanha-thinkpad.redhat.com>

On 2014-11-03 at 16:05, Stefan Hajnoczi wrote:
> On Mon, Nov 03, 2014 at 11:25:10AM +0100, Kevin Wolf wrote:
>> Am 03.11.2014 um 09:54 hat Markus Armbruster geschrieben:
>>> Kevin Wolf <kwolf@redhat.com> writes:
>>>
>>>> Am 31.10.2014 um 12:24 hat Stefan Hajnoczi geschrieben:
>>>>> On Thu, Oct 30, 2014 at 10:36:35AM +0100, Kevin Wolf wrote:
>>>>>> Am 30.10.2014 um 10:27 hat Stefan Hajnoczi geschrieben:
>>>>>>> The guest may legitimately use raw devices that contain image format
>>>>>>> data.  Imagine tools similar to libguestfs.
>>>>>>>
>>>>>>> It's perfectly okay for them to lay out image format data onto a raw
>>>>>>> device.
>>>>>>>
>>>>>>> Probing is the problem, not putting image format data onto a raw device.
>>>>>> Agreed, that's why any restrictions only apply when probing was used to
>>>>>> detect a raw image. If you want to do anything exotic like storing a
>>>>>> qcow2 image for nested virt on a disk that is a raw image in the host,
>>>>>> then making sure to pass format=raw shouldn't be too much.
>>>>> Because at that point the solution is way over-engineered.
>>>>>
>>>>> Probing checks should be in the QEMU command-line code, not sprinkled
>>>>> across the codebase and even at run-time.
>>>>>
>>>>> Isn't Markus approach much simpler and cleaner?
>>>> I don't think so. My code isn't "sprinkled across the codebase", it has
>>>> the checks right where the problem arises, in the raw block driver.
>>> Actually, that's not where the problem is.
>>>
>>> The guest writing funny things to its disks is *not* the problem, it's
>>> perfectly normal operation.  Probing untrusted images is the problem!
>> I think we all know it, but let's clearly state the real problem once
>> again to remind us what we're trying to do on a high level. The security
>> problem we're talking about is that some image formats can contain file
>> names, and the content of these files can be exposed (in some cases even
>> r/w) to the guest.
> That's too specific.  There are other cases:
>
> Imagine you are paying for a 10 GB disk KVM virtual server with a
> hosting provider.
>
> The hosting provider did not configure KVM correctly and they use
> probing.  You can write a qcow2 header with a 100 GB disk size to the
> raw disk and reboot the VM.
>
> Suddenly your guest has access to 100 GB of disk space even though you
> are only paying for 10 GB!
>
>> Therefore not probing, but using untrusted images is the root problem -
>> but it's not one that we can fix. If the users downloads (or otherwise
>> obtains) an untrusted image with a bad backing file name, and of course
>> the correct file extension, we don't have a chance to protect them.
> This is driving the discussion into the wrong direction.  You are right
> that QEMU cannot solve that but it's also a well-known problem that
> OpenStack and co solved a long time ago.
>
>> What we can do something about is a special case of this, where a
>> malicious guest tries to turn a (trusted) image into something that
>> isn't trustworthy any more. In my book, the bad action is modifying the
>> image so that it looks like a different format with a bad header, it's
>> not treating an image file like what it looks like. If you disable
>> probing in qemu, you still allow qemu guests to write bad headers that
>> can fool other tools.
>>
>> The problem really isn't all the non-raw formats that have a header
>> which can contain file names. The problem is with raw which doesn't have
>> a header and allows the guest to turn its image file into any other file
>> type it wants and can potentially trick the user. raw is really a bad
>> format (or actually, it's a non-format), and if I could choose I
>> wouldn't support it, or at least only r/o. We should instead have used a
>> format with a header and then the raw file shifted by some offset. It's
>> too late for that, though.
>>
>> But coming back to your specific statement: Probing images isn't the
>> problem. The guest writing funny things isn't the problem either. Using
>> a format that can't reliably represent those funny things is the
>> problem. And if the format can't reliably represent something, it should
>> return an error when you try to do it anyway. If you need the feature of
>> storing funny things, use a format that supports it reliably. (And
>> calling explicit format=raw reliable isn't quite right either, but it's
>> a compromise I'd be willing to make.)
> I don't follow this logic.  You end up with "raw is bad because it
> doesn't have a header".  That doesn't get us anywhere.

It's true anyway. Just because an argument is not constructive does not 
mean it's bad, as long as it's true.

> (There are other formats that can also be confused.  For example, you
> can create a qcow2 file that is also a vpc file because vpc allows files
> that have only a footer.)

Then vpc is bad, too.

> Fact remains that you must not probe untrusted guest disk images.

Nobody wants to completely abolish probing. Markus only wants to use the 
extension as a second source of information, basically.

> The argument that there might not be a traditional filename doesn't make
> sense to me.  When there is no filename the command-line is already
> sufficiently complex and usage is fancy enough that probing adds no
> convenience, the user can just specify the format.

Apropos "the cloud provider did not configure KVM correctly"?

> Anyway, does this sound reasonable:
>
> In QEMU 3.0, require the format= option for -drive.  Keep probing the
> way it is for non-drive options because they are used for convenience by
> local users.

To me it does, yes.

Max

  reply	other threads:[~2014-11-03 15:13 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 16:03 [Qemu-devel] [PATCH RFC 0/2] block: Warn on insecure format probing Markus Armbruster
2014-10-28 16:03 ` [Qemu-devel] [PATCH RFC 1/2] block: Factor bdrv_probe_all() out of find_image_format() Markus Armbruster
2014-10-28 16:34   ` Eric Blake
2014-10-28 16:41   ` Jeff Cody
2014-10-29 15:22   ` Stefan Hajnoczi
2014-10-28 16:03 ` [Qemu-devel] [PATCH RFC 2/2] block: Warn on insecure format probing Markus Armbruster
2014-10-28 17:02   ` Eric Blake
2014-10-28 18:29     ` Jeff Cody
2014-10-28 18:56       ` Eric Blake
2014-10-28 19:42         ` Jeff Cody
2014-10-29  7:36           ` Markus Armbruster
2014-10-29  8:25             ` Max Reitz
2014-10-29  7:22         ` Markus Armbruster
2014-10-30 13:58           ` Jeff Cody
2014-11-03  8:07             ` Markus Armbruster
2014-10-29  7:03     ` Markus Armbruster
2014-10-28 18:33   ` Jeff Cody
2014-10-29  6:37     ` Markus Armbruster
2014-10-30 13:52       ` Jeff Cody
2014-11-03  8:11         ` Markus Armbruster
2014-10-29  1:16   ` Fam Zheng
2014-10-29  6:32     ` Markus Armbruster
2014-10-29 10:12   ` Kevin Wolf
2014-10-29 13:54     ` Markus Armbruster
2014-10-29 15:34       ` Stefan Hajnoczi
2014-10-30  9:07         ` Markus Armbruster
2014-10-30  9:24           ` Stefan Hajnoczi
2014-10-30 12:19             ` Markus Armbruster
2014-10-30  9:30       ` Kevin Wolf
2014-10-30 12:49         ` Markus Armbruster
2014-10-31 11:19           ` Stefan Hajnoczi
2014-10-31 22:45           ` Eric Blake
2014-11-03  8:15             ` Markus Armbruster
2014-11-03 11:13             ` Kevin Wolf
2014-11-04  9:36               ` Markus Armbruster
2014-11-04 10:32                 ` Kevin Wolf
2014-11-05  7:58                   ` Markus Armbruster
2014-11-03 11:00           ` Kevin Wolf
2014-11-04  9:39             ` Markus Armbruster
2014-11-04 16:09               ` Jeff Cody
2014-11-05  8:05                 ` Markus Armbruster
2014-11-05  8:09                   ` Max Reitz
2014-10-30  9:08   ` Max Reitz
2014-10-30  9:27     ` Stefan Hajnoczi
2014-10-30  9:36       ` Kevin Wolf
2014-10-31 11:24         ` Stefan Hajnoczi
2014-10-31 11:56           ` Kevin Wolf
2014-11-03  8:54             ` Markus Armbruster
2014-11-03  9:11               ` Max Reitz
2014-11-04  9:34                 ` Markus Armbruster
2014-11-03 10:25               ` Kevin Wolf
2014-11-03 15:05                 ` Stefan Hajnoczi
2014-11-03 15:13                   ` Max Reitz [this message]
2014-11-04  9:42                   ` Markus Armbruster
2014-11-04 10:11                   ` Kevin Wolf
2014-11-04 15:25                     ` Stefan Hajnoczi
2014-11-04 15:37                       ` Kevin Wolf
2014-11-05  8:39                         ` Markus Armbruster
2014-11-05 10:18                           ` Eric Blake
2014-10-30 13:02     ` Markus Armbruster
2014-11-03  8:44       ` Max Reitz
2014-10-30 20:45   ` Richard W.M. Jones
2014-11-03  8:18     ` Markus Armbruster

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=54579B7E.4000605@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).