qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Cc: jcody@redhat.com, qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH RFC 2/2] block: Warn on insecure format probing
Date: Wed, 05 Nov 2014 11:18:00 +0100	[thread overview]
Message-ID: <5459F958.7020705@redhat.com> (raw)
In-Reply-To: <87d292ujmg.fsf@blackfin.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 3049 bytes --]

On 11/05/2014 09:39 AM, Markus Armbruster wrote:

>> Hm... In which cases does libvirt probe the image format? And is it even
>> consistent with qemu today?
> 
> I had a quick look at the source.  Eric, please correct
> misunderstandings.
> 
> Enumation type virStorageFileProbeFormat enumerates supported formats.
> It has pseudo-formats VIR_STORAGE_FILE_AUTO, VIR_STORAGE_FILE_AUTO_SAFE.

VIR_STORAGE_FILE_AUTO is the format that libvirt assigns an image where
the libvirt XML was not explicit.  VIR_STORAGE_FILE_AUTO_SAFE is what
the image gets reassigned to for QED (as the only format where the
backing format is mandatory as part of the backing chain), which
basically says: trust the backing chain if the XML omitted a type,
instead of doing the normal rules of auto.

> 
> I don't understand VIR_STORAGE_FILE_AUTO_SAFE offhand.
> 
> VIR_STORAGE_FILE_AUTO means probing.  Its use appears to be deprecated.

Close.  It actually means: "the user did not specify a format in their
XML, so it is now up to a configuration knob whether we will probe or
whether we will forcefully error out and tell the user to fix their
XML".  The configuration knob (allow_disk_format_probing in
/etc/libvirt/qemu.conf) defaults to 0 by default (error out and tell the
user to fix their XML) but can be overridden to 1 by someone that knows
what they are doing (probes are allowed at the user's own risk).

> Actual probing happens in virStorageFileProbeFormatFromBuf():
> 
>     For all formats:
>         if magic and version match, pick this format
> 
>     If some magic matched, but not the version: warn
> 
>     For all formats:
>         if file name extension matches, pick this format
> 
>     Pick raw.
> 
> The formats' magic, version and extension are defined in fileTypeInfo[].
> 
> If I remember correctly, libvirt has its own probing because running an
> external program just to probe is too slow.

Correct.  And while the libvirt probing was originally modeled after
qemu, the two approaches have probably diverged a bit over time.  An
obvious difference: qemu only probes 512? bytes (maybe 4096?), but
libvirt probes deep enough to determine the .iso file format (a 5-byte
magic number at decimal offset 32769).  See VIR_STORAGE_MAX_HEADER
0x8200 in src/util/virstoragefile.h.

> 
> Another reason for having its own probing might be providing a secure
> replacement for QEMU's insecure probing.

While that may be a possible outcome, I'm not sure it was an intentional
design.

> 
>> If you can get libvirt to explicitly pass the wrong format=... option
>> because it did its own probing, we have a problem no matter what we
>> change in qemu.
> 
> Yes, but that would be a libvirt problem.  No excuse for us to ignore
> our own problems.

Correct - for the purposes of this thread, we need only figure out how
to make qemu closer to being secure by default.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

  reply	other threads:[~2014-11-05 10:18 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
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 [this message]
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=5459F958.7020705@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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).