From: Harsh Prateek Bora <harshpb@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: Chinmay Rath <rathc@linux.ibm.com>, Lazymio <mio@lazym.io>,
Gautam Menghani <gautam@linux.ibm.com>
Subject: [PULL 4/6] hw/net/spapr_llan: validate RxBufPool fields on migration load
Date: Wed, 28 Oct 2026 10:50:22 +0530 [thread overview]
Message-ID: <20261028052024.38377-5-harshpb@linux.ibm.com> (raw)
In-Reply-To: <20261028052024.38377-1-harshpb@linux.ibm.com>
From: Chinmay Rath <rathc@linux.ibm.com>
vmstate_rx_buffer_pool restores count and bufsize as raw int32 values
with no bounds checking. A crafted migration stream can set count to
any int32 value. spapr_vlan_get_rx_bd_from_pool() then passes the
count > 0 guard, decrements count, and uses the result as an array
index into bds[], a 4096-entry fixed heap allocation:
dev->rx_pool[pool]->count--;
bd = dev->rx_pool[pool]->bds[dev->rx_pool[pool]->count]; /* OOB read */
dev->rx_pool[pool]->bds[dev->rx_pool[pool]->count] = 0; /* OOB write */
With count == INT32_MAX this lands ~17 GiB past the start of a 32 KiB
heap object. Additionally, a negative bufsize silently compares as a
huge value when widened to size_t, defeating the bufsize >= size + 8
pool-selection guard.
The hypercall path (spapr_vlan_add_rxbuf_to_pool) already enforces
0 <= count < RX_POOL_MAX_BDS; add a post_load hook to
vmstate_rx_buffer_pool that rejects any stream violating the same
invariant, failing the incoming migration.
Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4147
Reported-by: Lazymio <mio@lazym.io>
Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Reviewed-by: Gautam Menghani <gautam@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20260917202854.288439-1-rathc@linux.ibm.com
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
---
hw/net/spapr_llan.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index 550848307d..a5b8906849 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -800,11 +800,29 @@ static bool spapr_vlan_rx_buffer_pools_needed(void *opaque)
return (dev->compat_flags & SPAPRVLAN_FLAG_RX_BUF_POOLS) != 0;
}
+static int spapr_vlan_rx_buffer_pool_post_load(void *opaque, int version_id)
+{
+ RxBufPool *rxp = opaque;
+
+ if (rxp->count < 0 || rxp->count > RX_POOL_MAX_BDS) {
+ return -EINVAL;
+ }
+ /*
+ * bufsize is compared against a size_t in spapr_vlan_get_rx_bd_from_pool(),
+ * so a negative value would compare as huge.
+ */
+ if (rxp->bufsize < 0) {
+ return -EINVAL;
+ }
+ return 0;
+}
+
static const VMStateDescription vmstate_rx_buffer_pool = {
.name = "spapr_llan/rx_buffer_pool",
.version_id = 1,
.minimum_version_id = 1,
.needed = spapr_vlan_rx_buffer_pools_needed,
+ .post_load = spapr_vlan_rx_buffer_pool_post_load,
.fields = (const VMStateField[]) {
VMSTATE_INT32(bufsize, RxBufPool),
VMSTATE_INT32(count, RxBufPool),
--
2.52.0
next prev parent reply other threads:[~2026-10-28 5:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 5:20 [PULL 0/6] ppc queue for 2026-10-28 Harsh Prateek Bora
2026-10-28 5:20 ` [PULL 1/6] hw/pci-host/pnv_phb4: fix guest-triggerable abort on 8-byte config access Harsh Prateek Bora
2026-10-28 5:20 ` [PULL 2/6] tests/functional/ppc64: extend pseries migration tests Harsh Prateek Bora
2026-10-28 5:20 ` [PULL 3/6] tests/functional/ppc64: extend ppc64 powernv net device tests Harsh Prateek Bora
2026-10-28 5:20 ` Harsh Prateek Bora [this message]
2026-10-28 5:20 ` [PULL 5/6] hw/ppc/spapr: Add the "rtas-version" property to /rtas Harsh Prateek Bora
2026-10-28 5:20 ` [PULL 6/6] spapr-vscsi: clamp adapter info DMA write length to struct size Harsh Prateek Bora
2026-10-28 11:20 ` [PULL 0/6] ppc queue for 2026-10-28 Richard Henderson
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=20261028052024.38377-5-harshpb@linux.ibm.com \
--to=harshpb@linux.ibm.com \
--cc=gautam@linux.ibm.com \
--cc=mio@lazym.io \
--cc=qemu-devel@nongnu.org \
--cc=rathc@linux.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.