All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Fabiano Rosas" <farosas@suse.de>,
	qemu-devel@nongnu.org, "Stefano Garzarella" <sgarzare@redhat.com>,
	김승중 <seungjung0711@gmail.com>,
	"Alexandr Moshkov" <dtalexundeer@yandex-team.ru>
Subject: Re: [PATCH] vhost/migration: Fix incorrect size used in inflight->addr in VMSD
Date: Thu, 30 Jul 2026 12:14:26 -0400	[thread overview]
Message-ID: <amt4Yv8miJ_rFYSS@x1.local> (raw)
In-Reply-To: <20260729180727-mutt-send-email-mst@kernel.org>

On Wed, Jul 29, 2026 at 06:08:27PM -0400, Michael S. Tsirkin wrote:
> On Wed, Jul 29, 2026 at 03:27:01PM -0400, Peter Xu wrote:
> > On Wed, Jul 29, 2026 at 02:57:57PM -0400, Michael S. Tsirkin wrote:
> > > On Wed, Jul 29, 2026 at 01:48:25PM -0400, Peter Xu wrote:
> > > > So to me, it's much simpler we say migration stream must be
> > > > trusted, and I expect dest QEMU can allocate any buffer it needs, until it
> > > > eats the whole system memory.  I really don't see much real risk..
> > > 
> > > It's not risk due to migration, specifically. But making qemu
> > > drink up terabytes from the guest would be problematic, right?
> > > 
> > > Putting qemu in a cgroup with restricted total memory
> > > would be one way to prevent this class of security issue,
> > > and a robust one.
> > > 
> > > But that, in turn, is impossible if qemu insists on allocating
> > > unlimited memory at the drop of a hat.
> > 
> > Just to clarify at least one thing.. we have two attack surfaces here and
> > they're very different IMHO:
> > 
> > (1) guest behavior caused memory allocation, or,
> > 
> > (2) migration stream caused memory allocation.
> > 
> > AFAIU, (1) is more severe. All my points only apply to (2).
> 
> 
> Absolutely. Yet without fixing 2 we can't mitigate 1 with OS level
> protections.

Nowadays most of issues around migration stream can cause allocations are
about what we have already persisted internally to QEMU to maintain guest
states.

Takeing a GTree as example.

In guest context, one concrete example is GTree can contain unlimited
number of elements for a vIOMMU device to keep the mappings, before
migration we should better make sure the mapping isn't too much to eat all
host memory and get QEMU OOM killed.

In case of migration, it's about when migrating a GTree we will migrate
exactly whatever it is there already on src to dest, then a malicious
stream may cause unlimited allocations.  That's one of the security
reports, we have similar ones for qlist, etc.

IOW, I think yes if we stick with "migration stream trusted" all issues
should be non-issue, and we should not worry about (2) too much, because we
really should majorly need to worry (1).. which is real, since guest is
never trusted..

Meanwhile, migration should still make sure it won't allocate anything else
than what has already been there for source QEMU.  If we need such temp
allocation for migration only, that's the real part where a migration
security issue may reside, but so far none of the reports is about
that... I also can't think of a lot that migration does allocation on its
own for things that can occupy a lot of memory, some might be relevant I
can still think of is bitmaps all over, that's unfortunate, we need them
for various reasons, either on src/dst.. say, kvm also has bitmaps of such,
only allocated during migrations, not easily avoidable.

Another example is QEMU_VM_VMDESCRIPTION that is definitely migration
specific (not part of src QEMU), but dest is already careful there, in
qemu_loadvm_state():

    if (ret == 0 && should_send_vmdesc()) {
        ...
        if (section_type != QEMU_VM_VMDESCRIPTION) {
        ...
        } else {
            buf = g_malloc(0x1000);
            size = qemu_get_be32(f);

            while (size > 0) {
                uint32_t read_chunk = MIN(size, 0x1000);
                qemu_get_buffer(f, buf, read_chunk);
                size -= read_chunk;
            }
            g_free(buf);
        }

I also remember VFIO has some internal buffering only used in migration, I
also remember when I reviewed it I tried to point out the buffer limitation
issue I hope it was properly settled..

I hope we're always careful on those otherwise, but these cases should be
rare.

Thanks,

-- 
Peter Xu



  reply	other threads:[~2026-07-30 16:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 15:39 [PATCH] vhost/migration: Fix incorrect size used in inflight->addr in VMSD Peter Xu
2026-07-28 20:57 ` Fabiano Rosas
2026-07-29 14:00   ` Peter Xu
2026-07-29 14:25     ` Michael S. Tsirkin
2026-07-29 14:27     ` Fabiano Rosas
2026-07-29 15:44       ` Peter Xu
2026-07-29 16:13         ` Fabiano Rosas
2026-07-29 17:40           ` Peter Xu
2026-07-29 17:48           ` Peter Xu
2026-07-29 18:57             ` Michael S. Tsirkin
2026-07-29 19:27               ` Peter Xu
2026-07-29 22:08                 ` Michael S. Tsirkin
2026-07-30 16:14                   ` Peter Xu [this message]
2026-07-28 23:17 ` Michael S. Tsirkin
2026-07-29  7:25 ` Alexandr Moshkov
2026-07-29  8:49   ` Michael S. Tsirkin
2026-07-29 14:16     ` Peter Xu

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=amt4Yv8miJ_rFYSS@x1.local \
    --to=peterx@redhat.com \
    --cc=dtalexundeer@yandex-team.ru \
    --cc=farosas@suse.de \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seungjung0711@gmail.com \
    --cc=sgarzare@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 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.