All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>, qemu-devel@nongnu.org
Cc: peterx@redhat.com, Juraj Marcin <jmarcin@redhat.com>,
	Feifan Qian <bea1e@proton.me>,
	qemu-stable <qemu-stable@nongnu.org>,
	Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH 1/5] migration: Fix possible overflow in vmstate_handle_alloc()
Date: Tue, 28 Jul 2026 16:19:32 -0300	[thread overview]
Message-ID: <87zezaoraz.fsf@suse.de> (raw)
In-Reply-To: <20260728155247.1894355-2-peterx@redhat.com>

Peter Xu <peterx@redhat.com> writes:

> Migration incoming side almost always trusted the stream data and allows
> allocation to happen with whatever size received.  With it, malicious
> migration stream can manipulate destination QEMU behavior on g_malloc(), in
> path of vmstate_handle_alloc() on specific VMSD fields.  Fix it by limiting
> all sizes with int32_t positive values (INT_MAX) explicitly.
>
> We have quite a few bug reports recently leveraging this defect. It can be
> reproduced in many ways for (I think) all archs binaries, but the simplest
> reproducer is:
>
>   $ hexdump -C ./vm.img
>   00000000  51 45 56 4d 00 00 00 03  07 80 00 00 00 00 00 00  |QEVM............|
>
>   $ ./qemu-system-x86_64 -incoming file:./vm.img
>   VNC server running on ::1:5900
>   qemu-system-x86_64: GLib: ../glib/gmem.c:106: failed to allocate 18446744071562067968 bytes
>   Aborted                    (core dumped) ./qemu-system-x86_64 -incoming file:./vm.img
>
> We could assert here, but since we have errp right above the stack this
> patch routes the errp over to allow destination QEMU fail gracefully.  This
> means there's no way to DoS coredumpctl as well because we don't generate
> core dumps at all. The output message could also hopefully help triage
> issues when it's not a malicious stream but only wrong image used.
>
> When at this, making sure multiplex also won't overflow.
>
> After patched:
>
>   $ ./qemu-system-x86_64 -incoming file:./vm.img
>   VNC server running on ::1:5900
>   qemu-system-x86_64: load of migration failed: Invalid argument: vmstate_size: VMState field 'name' overflow
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3805
> Reported-by: Feifan Qian <bea1e@proton.me>
> Reported-by: dong ling (@dongling226655)
> Cc: qemu-stable <qemu-stable@nongnu.org>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Fabiano Rosas <farosas@suse.de>
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Fabiano Rosas <farosas@suse.de>


  reply	other threads:[~2026-07-28 19:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 15:52 [PATCH 0/5] migration: Hardening fixes for 11.2 Peter Xu
2026-07-28 15:52 ` [PATCH 1/5] migration: Fix possible overflow in vmstate_handle_alloc() Peter Xu
2026-07-28 19:19   ` Fabiano Rosas [this message]
2026-07-28 15:52 ` [PATCH 2/5] migration/multifd: Validate next_packet_size in zlib/zstd recv Peter Xu
2026-07-28 19:44   ` Fabiano Rosas
2026-07-28 15:52 ` [PATCH 3/5] migration/multifd: Replace assert() with error_setg() in recv paths Peter Xu
2026-07-28 19:51   ` Fabiano Rosas
2026-07-28 20:28     ` Peter Xu
2026-07-28 20:59       ` Fabiano Rosas
2026-07-28 21:07         ` Peter Xu
2026-07-28 15:52 ` [PATCH 4/5] migration: Fix rare hang of migration_channel_read_peek() Peter Xu
2026-07-28 16:24   ` Daniel P. Berrangé
2026-07-28 17:09     ` Peter Xu
2026-07-28 17:12       ` Daniel P. Berrangé
2026-07-28 19:59       ` Fabiano Rosas
2026-07-28 20:46         ` Peter Xu
2026-07-28 21:00           ` Fabiano Rosas
2026-07-28 21:31             ` Peter Xu
2026-07-28 15:52 ` [PATCH 5/5] migration/ram: Check for RAMBlock size mismatch when parsing Peter Xu
2026-07-28 19:54   ` Fabiano Rosas

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=87zezaoraz.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=bea1e@proton.me \
    --cc=jmarcin@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /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.