Skip to contentSkip to conversation

9pfs: fix DoS via Treaddir (CVE-2026-9238)

PATCH In review Christian Schoenebeck 2 participants 13 messages Jun 12 – Jun 23

lore
Share & tools
lore
#0 lore raw

v2 cover 9pfs: fix DoS via Treaddir (CVE-2026-9238)

Feifan Qian reported a potential DoS and unbound host allocation via Treaddir request due to msize not being capped on Tversion handshake, and allocation size in Treaddir being capped too late.

Attack Vector of Vulnerability:

A malicious guest can negotiate a large 9P msize during Tversion handshake and then send Treaddir request with a large 'count' parameter. The 9p server would allocate host memory proportional to the negotiated 'msize' for collecting directory entries, before validating that the actual reply buffer can hold the response. If the reply buffer is smaller than what was allocated, the response marshalling fails, but the memory has already been consumed.

This can lead to:

- Unbound host memory allocation proportional to the negotiated msize.
- Denial of service against the QEMU process.
- Potential OOM conditions affecting entire host system.

This series fixes this vulnerability on two layers.

Summary of patches fixing this vulnerability:

- Layer 1: Patches 1..4 cap msize during Tversion handshake to reasonable maximum value. It does so by limiting msize to the theoretical maximum msize value supported by transport implementation.

- Layer 2: Patches 5..8 cap the allocated host memory in the Treaddir handler specifically to the current, real response buffer size of transport implementation.

v2:
- Patch 3:
- Pick the smallest limit from all Xen rings.
- Return zero if Xen's ring count is zero.
- Patch 7:
- Use a local iovec in_sg[2] array variable to avoid potential NULL pointer dereference.
- Patch 8:
- Fix potential underflow if response_buffer_size() returned a value smaller than 11.

Christian Schoenebeck (8):
hw/9pfs: add msize_limit transport callback 9pfs/virtio: implement msize_limit callback 9pfs/xen: implement msize_limit callback hw/9pfs: cap negotiated msize to transport limit hw/9pfs: add response_buffer_size transport callback 9pfs/virtio: implement response_buffer_size callback 9pfs/xen: implement response_buffer_size callback hw/9pfs: cap Treaddir allocation (CVE-2026-9238)

 hw/9pfs/9p.c               | 34 ++++++++++++++++++++++++++++++++--
 hw/9pfs/9p.h               |  2 ++
 hw/9pfs/virtio-9p-device.c | 17 +++++++++++++++++
 hw/9pfs/xen-9p-backend.c   | 31 +++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 1/8 hw/9pfs: add msize_limit transport callback

Add a new callback 'msize_limit' to the V9fsTransport structure.

This allows each transport implementation to provide its theoretical maximum 'msize' value, which will be used to cap the negotiated msize during Tversion handshake.

---
 hw/9pfs/9p.h | 1 +
 1 file changed, 1 insertion(+)
hw/9pfs/9p.h +1 -0
index 65cc45e344..14111e041a 100644
@@ -481,6 +481,7 @@ struct V9fsTransport {
     void        (*init_out_iov_from_pdu)(V9fsPDU *pdu, struct iovec **piov,
                                          unsigned int *pniov, size_t size);
     void        (*push_and_notify)(V9fsPDU *pdu);
+    size_t      (*msize_limit)(V9fsState *s);
 };
 
 #endif
Signature · 1 line
2.47.3
#2 lore raw

PATCH v2 2/8 9pfs/virtio: implement msize_limit callback

In reply to Christian Schoenebeck

Add and implement the msize_limit callback for the virtio transport.

This new callback function provides the theoretical maximum 'msize' value supported by this virtio transport.

The limit is calculated as (VIRTQUEUE_MAX_SIZE - 2) * 4096 bytes, where 2 virtio descriptors are lost exactly for:

- 1 descriptor for the original request (typically being small)

- 1 descriptor as indirect table pointer (when used), which just contains a pointer to the separate sglist containing the response's actual payload data

And 4096 bytes are assumed as standard page size used by Linux 9p client. This results in a maximum 'msize' of 4186112 bytes.

Theoretically Linux client could support a much larger size, e.g. by using multiple consecutive pages per sg entry / descriptor. However that's currently not the case and unlikely to change any time soon. And due to recent security issues, let's handle this limit conservatively until really necessary to be raised.

---
 hw/9pfs/virtio-9p-device.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/9pfs/virtio-9p-device.c +7 -0
index 9f70e2338c..8c5d86cb66 100644
@@ -192,12 +192,19 @@ static void virtio_init_out_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
     *pniov = elem->out_num;
 }
 
+static size_t virtio_9p_msize_limit(V9fsState *s)
+{
+    const size_t guestPageSize = 4096;
+    return (VIRTQUEUE_MAX_SIZE - 2) * guestPageSize;
+}
+
 static const V9fsTransport virtio_9p_transport = {
     .pdu_vmarshal = virtio_pdu_vmarshal,
     .pdu_vunmarshal = virtio_pdu_vunmarshal,
     .init_in_iov_from_pdu = virtio_init_in_iov_from_pdu,
     .init_out_iov_from_pdu = virtio_init_out_iov_from_pdu,
     .push_and_notify = virtio_9p_push_and_notify,
+    .msize_limit = virtio_9p_msize_limit,
 };
 
 static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
Signature · 1 line
2.47.3
#3 lore raw

PATCH v2 3/8 9pfs/xen: implement msize_limit callback

In reply to Christian Schoenebeck

Add and implement the msize_limit callback for the Xen transport.

The limit is calculated using XEN_FLEX_RING_SIZE() based on the negotiated ring_order. For the theoretical maximum ring_order of 9, this results in a maximum 'msize' of 1048576 bytes (1 MiB).

The minimum limit of all rings is picked, because multiple rings could theoretically have different ring_orders.

---
 hw/9pfs/xen-9p-backend.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
hw/9pfs/xen-9p-backend.c +19 -0
index ca0fff5fa9..e31124bcf5 100644
@@ -250,12 +250,31 @@ static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
     qemu_bh_schedule(ring->bh);
 }
 
+static size_t xen_9p_msize_limit(V9fsState *s)
+{
+    Xen9pfsDev *xen_9pfs = container_of(s, Xen9pfsDev, state);
+    size_t limit;
+    int i;
+
+    if (!xen_9pfs->num_rings) {
+        return 0;
+    }
+
+    limit = XEN_FLEX_RING_SIZE(xen_9pfs->rings[0].ring_order);
+    for (i = 1; i < xen_9pfs->num_rings; i++) {
+        limit = MIN(limit, XEN_FLEX_RING_SIZE(xen_9pfs->rings[i].ring_order));
+    }
+
+    return limit;
+}
+
 static const V9fsTransport xen_9p_transport = {
     .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
     .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
     .init_in_iov_from_pdu = xen_9pfs_init_in_iov_from_pdu,
     .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
     .push_and_notify = xen_9pfs_push_and_notify,
+    .msize_limit = xen_9p_msize_limit,
 };
 
 static int xen_9pfs_init(struct XenLegacyDevice *xendev)
Signature · 1 line
2.47.3
Reviewed-by on v2 3/8
#4 lore raw

Re: [PATCH v2 3/8] 9pfs/xen: implement msize_limit callback

Quoted 10 lines · Christian Schoenebeck

Add and implement the msize_limit callback for the Xen transport.

The limit is calculated using XEN_FLEX_RING_SIZE() based on the negotiated ring_order. For the theoretical maximum ring_order of 9, this results in a maximum 'msize' of 1048576 bytes (1 MiB).

The minimum limit of all rings is picked, because multiple rings could theoretically have different ring_orders.

Quoted 43 lines
---
 hw/9pfs/xen-9p-backend.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
hw/9pfs/xen-9p-backend.c +19 -0
index ca0fff5fa9..e31124bcf5 100644
@@ -250,12 +250,31 @@ static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
     qemu_bh_schedule(ring->bh);
 }
 
+static size_t xen_9p_msize_limit(V9fsState *s)
+{
+    Xen9pfsDev *xen_9pfs = container_of(s, Xen9pfsDev, state);
+    size_t limit;
+    int i;
+
+    if (!xen_9pfs->num_rings) {
+        return 0;
+    }
+
+    limit = XEN_FLEX_RING_SIZE(xen_9pfs->rings[0].ring_order);
+    for (i = 1; i < xen_9pfs->num_rings; i++) {
+        limit = MIN(limit, XEN_FLEX_RING_SIZE(xen_9pfs->rings[i].ring_order));
+    }
+
+    return limit;
+}
+
 static const V9fsTransport xen_9p_transport = {
     .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
     .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
     .init_in_iov_from_pdu = xen_9pfs_init_in_iov_from_pdu,
     .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
     .push_and_notify = xen_9pfs_push_and_notify,
+    .msize_limit = xen_9p_msize_limit,
 };
 
 static int xen_9pfs_init(struct XenLegacyDevice *xendev)
Signature · 1 line
2.47.3
#5 lore raw

PATCH v2 4/8 hw/9pfs: cap negotiated msize to transport limit

In reply to Christian Schoenebeck

The 'msize' parameter negotiated during Tversion handshake can be arbitrarily large as requested by the guest. So far 9p server accepted any msize value suggested by guest, i.e. server did not cap it at all, no matter how large, as in practice the upper limit of msize is a client capability. But as subsequent's security patch shows, capping msize on server side makes sense as additional safety-net.

Let's cap msize to transport's theoretical limit for msize, mainly to prevent a bad client from triggering excessive host memory allocations throughout the session.

We intentionally don't cap msize to transport's current, real response buffer size, as the response buffer size may vary between individual requests.

---
 hw/9pfs/9p.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/9pfs/9p.c +10 -0
index e2713b9eee..2bb42dfc2e 100644
@@ -1456,6 +1456,16 @@ static void coroutine_fn v9fs_version(void *opaque)
         goto out;
     }
 
+    /* cap msize to transport's theoretical limit */
+    if (s->transport->msize_limit) {
+        size_t limit = s->transport->msize_limit(s);
+        if (s->msize > limit) {
+            s->msize = limit;
+            warn_report_once("9p: client msize capped to %zu (transport limit)",
+                             limit);
+        }
+    }
+
     /* 8192 is the default msize of Linux clients */
     if (s->msize <= 8192 && !(s->ctx.export_flags & V9FS_NO_PERF_WARN)) {
         warn_report_once(
Signature · 1 line
2.47.3
#6 lore raw

PATCH v2 5/8 hw/9pfs: add response_buffer_size transport callback

In reply to Christian Schoenebeck

Add a new callback to the V9fsTransport interface that allows each transport to provide the real size of its current response buffer.

This is needed for subsequent safety guards that will limit generated responses appropriately before trying to allocate, generate, and send a response to guest.

This is especially required for request handlers that need to allocate dynamic and potentially large host memory for generating a response. These safety guards are mandatory to counter bad clients that try to trick server by supplying response buffers being smaller than the previously negotiated msize value.

---
 hw/9pfs/9p.h | 1 +
 1 file changed, 1 insertion(+)
hw/9pfs/9p.h +1 -0
index 14111e041a..1efe000f6f 100644
@@ -482,6 +482,7 @@ struct V9fsTransport {
                                          unsigned int *pniov, size_t size);
     void        (*push_and_notify)(V9fsPDU *pdu);
     size_t      (*msize_limit)(V9fsState *s);
+    size_t      (*response_buffer_size)(V9fsPDU *pdu);
 };
 
 #endif
Signature · 1 line
2.47.3
#7 lore raw

PATCH v2 6/8 9pfs/virtio: implement response_buffer_size callback

In reply to Christian Schoenebeck

Add and implement the response_buffer_size callback for the virtio transport.

Returns the actual current virtio response buffer size for the supplied PDU, which will be used as safety guard for limiting the response size when generating a 9p response.

---
 hw/9pfs/virtio-9p-device.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/9pfs/virtio-9p-device.c +10 -0
index 8c5d86cb66..50dc93091d 100644
@@ -198,6 +198,15 @@ static size_t virtio_9p_msize_limit(V9fsState *s)
     return (VIRTQUEUE_MAX_SIZE - 2) * guestPageSize;
 }
 
+static size_t virtio_9p_response_buffer_size(V9fsPDU *pdu)
+{
+    V9fsState *s = pdu->s;
+    V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
+    VirtQueueElement *elem = v->elems[pdu->idx];
+
+    return iov_size(elem->in_sg, elem->in_num);
+}
+
 static const V9fsTransport virtio_9p_transport = {
     .pdu_vmarshal = virtio_pdu_vmarshal,
     .pdu_vunmarshal = virtio_pdu_vunmarshal,
@@ -205,6 +214,7 @@ static const V9fsTransport virtio_9p_transport = {
     .init_out_iov_from_pdu = virtio_init_out_iov_from_pdu,
     .push_and_notify = virtio_9p_push_and_notify,
     .msize_limit = virtio_9p_msize_limit,
+    .response_buffer_size = virtio_9p_response_buffer_size,
 };
 
 static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
Signature · 1 line
2.47.3
#8 lore raw

PATCH v2 7/8 9pfs/xen: implement response_buffer_size callback

In reply to Christian Schoenebeck

Add and implement the response_buffer_size callback for the Xen transport.

Returns the size of the response buffer from the rings in_sg, as limit for 9p server while generating a response for supplied PDU.

We use a local iovec array variable in_sg[2] instead of ring->sg, as ring->sg is only allocated by init_in_iov_from_pdu() and init_out_iov_from_pdu() during request / response processing. response_buffer_size() however may be called before those allocators, which would dereference ring->sg as NULL pointer. The local array avoids this.

---
 hw/9pfs/xen-9p-backend.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/9pfs/xen-9p-backend.c +12 -0
index e31124bcf5..24c90d97ec 100644
@@ -268,6 +268,17 @@ static size_t xen_9p_msize_limit(V9fsState *s)
     return limit;
 }
 
+static size_t xen_9pfs_response_buffer_size(V9fsPDU *pdu)
+{
+    Xen9pfsDev *priv = container_of(pdu->s, Xen9pfsDev, state);
+    Xen9pfsRing *ring = &priv->rings[pdu->tag % priv->num_rings];
+    struct iovec in_sg[2];
+    int num;
+
+    xen_9pfs_in_sg(ring, in_sg, &num, pdu->idx, 0);
+    return iov_size(in_sg, num);
+}
+
 static const V9fsTransport xen_9p_transport = {
     .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
     .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
@@ -275,6 +286,7 @@ static const V9fsTransport xen_9p_transport = {
     .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
     .push_and_notify = xen_9pfs_push_and_notify,
     .msize_limit = xen_9p_msize_limit,
+    .response_buffer_size = xen_9pfs_response_buffer_size,
 };
 
 static int xen_9pfs_init(struct XenLegacyDevice *xendev)
Signature · 1 line
2.47.3
Reviewed-by on v2 7/8
#9 lore raw

Re: [PATCH v2 7/8] 9pfs/xen: implement response_buffer_size callback

Quoted 6 lines · Christian Schoenebeck

Add and implement the response_buffer_size callback for the Xen transport.

Returns the size of the response buffer from the rings in_sg, as limit for 9p server while generating a response for supplied PDU.

Quoted 8 lines

We use a local iovec array variable in_sg[2] instead of ring->sg, as ring->sg is only allocated by init_in_iov_from_pdu() and init_out_iov_from_pdu() during request / response processing. response_buffer_size() however may be called before those allocators, which would dereference ring->sg as NULL pointer. The local array avoids this.

Quoted 37 lines
---
 hw/9pfs/xen-9p-backend.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/9pfs/xen-9p-backend.c +12 -0
index e31124bcf5..24c90d97ec 100644
@@ -268,6 +268,17 @@ static size_t xen_9p_msize_limit(V9fsState *s)
     return limit;
 }
 
+static size_t xen_9pfs_response_buffer_size(V9fsPDU *pdu)
+{
+    Xen9pfsDev *priv = container_of(pdu->s, Xen9pfsDev, state);
+    Xen9pfsRing *ring = &priv->rings[pdu->tag % priv->num_rings];
+    struct iovec in_sg[2];
+    int num;
+
+    xen_9pfs_in_sg(ring, in_sg, &num, pdu->idx, 0);
+    return iov_size(in_sg, num);
+}
+
 static const V9fsTransport xen_9p_transport = {
     .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
     .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
@@ -275,6 +286,7 @@ static const V9fsTransport xen_9p_transport = {
     .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
     .push_and_notify = xen_9pfs_push_and_notify,
     .msize_limit = xen_9p_msize_limit,
+    .response_buffer_size = xen_9pfs_response_buffer_size,
 };
 
 static int xen_9pfs_init(struct XenLegacyDevice *xendev)
Signature · 1 line
2.47.3
#10 lore raw

PATCH v2 8/8 hw/9pfs: cap Treaddir allocation (CVE-2026-9238)

In reply to Christian Schoenebeck

Constrain max_count in v9fs_readdir() to transport's current, real response buffer size before calling v9fs_do_readdir() to prevent excessive host memory allocation for specific, crafted, huge directories (large amount of entries) by bad clients.

Client may send a Treaddir request with a large 'count' parameter, and while the negotiated 'msize' provides some limit, it accounts for guest being somewhat faithful on the negotiated 'msize' value throughout the session.

A bad guest client could have negotiated a large 'msize' but provide a small reply buffer for Treaddir request, causing QEMU to allocate host memory proportional to 'msize' before discovering the reply cannot fit.

Possible consequence was a potential DoS by a priviliged guest, causing a disconnection of guest communication due to transport device being marked as "broken", however QEMU process would have continued to run with potentially giant host memory allocation, which might have negative impact on other services running on host.

Fixes CVE-2026-9238
Fixes 2149675b195f ("9pfs: add new function v9fs_co_readdir_many()")
---
 hw/9pfs/9p.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
hw/9pfs/9p.c +22 -2
index 2bb42dfc2e..c3e78779b7 100644
@@ -2652,6 +2652,7 @@ static void coroutine_fn v9fs_readdir(void *opaque)
     uint32_t max_count;
     V9fsPDU *pdu = opaque;
     V9fsState *s = pdu->s;
+    size_t max_resp_sz;
 
     retval = pdu_unmarshal(pdu, offset, "dqd", &fid,
                            &initial_offset, &max_count);
@@ -2660,9 +2661,28 @@ static void coroutine_fn v9fs_readdir(void *opaque)
     }
     trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, max_count);
 
+    max_resp_sz = s->msize;
+
+    /*
+     * Constrain max_count to transport's current, actual response buffer size.
+     * A bad client might provide a response buffer < msize.
+     */
+    if (s->transport->response_buffer_size) {
+        size_t buf_size = s->transport->response_buffer_size(pdu);
+        if (max_resp_sz > buf_size) {
+            max_resp_sz = buf_size;
+        }
+    }
+
     /* Enough space for a R_readdir header: size[4] Rreaddir tag[2] count[4] */
-    if (max_count > s->msize - 11) {
-        max_count = s->msize - 11;
+    if (max_resp_sz > 11) {
+        max_resp_sz -= 11;
+    } else {
+        max_resp_sz = 0;
+    }
+
+    if (max_count > max_resp_sz) {
+        max_count = max_resp_sz;
         warn_report_once(
             "9p: bad client: T_readdir with count > msize - 11"
         );
Signature · 1 line
2.47.3
Reviewed-by on v2 8/8
#11 lore raw

Re: [PATCH v2 8/8] hw/9pfs: cap Treaddir allocation (CVE-2026-9238)

Quoted 20 lines · Christian Schoenebeck

Constrain max_count in v9fs_readdir() to transport's current, real response buffer size before calling v9fs_do_readdir() to prevent excessive host memory allocation for specific, crafted, huge directories (large amount of entries) by bad clients.

Client may send a Treaddir request with a large 'count' parameter, and while the negotiated 'msize' provides some limit, it accounts for guest being somewhat faithful on the negotiated 'msize' value throughout the session.

A bad guest client could have negotiated a large 'msize' but provide a small reply buffer for Treaddir request, causing QEMU to allocate host memory proportional to 'msize' before discovering the reply cannot fit.

Possible consequence was a potential DoS by a priviliged guest, causing a disconnection of guest communication due to transport device being marked as "broken", however QEMU process would have continued to run with potentially giant host memory allocation, which might have negative impact on other services running on host.

Quoted 4 lines
Fixes CVE-2026-9238
Fixes 2149675b195f ("9pfs: add new function v9fs_co_readdir_many()")
Quoted 50 lines
---
 hw/9pfs/9p.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
hw/9pfs/9p.c +22 -2
index 2bb42dfc2e..c3e78779b7 100644
@@ -2652,6 +2652,7 @@ static void coroutine_fn v9fs_readdir(void *opaque)
     uint32_t max_count;
     V9fsPDU *pdu = opaque;
     V9fsState *s = pdu->s;
+    size_t max_resp_sz;
 
     retval = pdu_unmarshal(pdu, offset, "dqd", &fid,
                            &initial_offset, &max_count);
@@ -2660,9 +2661,28 @@ static void coroutine_fn v9fs_readdir(void *opaque)
     }
     trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, max_count);
 
+    max_resp_sz = s->msize;
+
+    /*
+     * Constrain max_count to transport's current, actual response buffer size.
+     * A bad client might provide a response buffer < msize.
+     */
+    if (s->transport->response_buffer_size) {
+        size_t buf_size = s->transport->response_buffer_size(pdu);
+        if (max_resp_sz > buf_size) {
+            max_resp_sz = buf_size;
+        }
+    }
+
     /* Enough space for a R_readdir header: size[4] Rreaddir tag[2] count[4] */
-    if (max_count > s->msize - 11) {
-        max_count = s->msize - 11;
+    if (max_resp_sz > 11) {
+        max_resp_sz -= 11;
+    } else {
+        max_resp_sz = 0;
+    }
+
+    if (max_count > max_resp_sz) {
+        max_count = max_resp_sz;
         warn_report_once(
             "9p: bad client: T_readdir with count > msize - 11"
         );
Signature · 1 line
2.47.3
#12 lore raw
In reply to Christian Schoenebeck
Quoted 14 lines · On Friday, 12 June 2026 20:22:52 CEST Christian Schoenebeck wrote:

Feifan Qian reported a potential DoS and unbound host allocation via Treaddir request due to msize not being capped on Tversion handshake, and allocation size in Treaddir being capped too late.

Attack Vector of Vulnerability:

A malicious guest can negotiate a large 9P msize during Tversion handshake and then send Treaddir request with a large 'count' parameter. The 9p server would allocate host memory proportional to the negotiated 'msize' for collecting directory entries, before validating that the actual reply buffer can hold the response. If the reply buffer is smaller than what was allocated, the response marshalling fails, but the memory has already been consumed.

Quoted 7 lines

This can lead to:

- Unbound host memory allocation proportional to the negotiated msize.
- Denial of service against the QEMU process.
- Potential OOM conditions affecting entire host system.

This series fixes this vulnerability on two layers.

Queued on 9p.next:
https://github.com/cschoenebeck/qemu/commits/9p.next

Thanks!

/Christian

Quoted 36 lines

Summary of patches fixing this vulnerability:

- Layer 1: Patches 1..4 cap msize during Tversion handshake to reasonable maximum value. It does so by limiting msize to the theoretical maximum msize value supported by transport implementation.

- Layer 2: Patches 5..8 cap the allocated host memory in the Treaddir
handler specifically to the current, real response buffer size of transport implementation.

v2:
- Patch 3:
- Pick the smallest limit from all Xen rings.
- Return zero if Xen's ring count is zero.
- Patch 7:
- Use a local iovec in_sg[2] array variable to avoid potential NULL pointer dereference.
- Patch 8:
- Fix potential underflow if response_buffer_size() returned a value smaller than 11.

Christian Schoenebeck (8):
hw/9pfs: add msize_limit transport callback 9pfs/virtio: implement msize_limit callback 9pfs/xen: implement msize_limit callback hw/9pfs: cap negotiated msize to transport limit hw/9pfs: add response_buffer_size transport callback 9pfs/virtio: implement response_buffer_size callback 9pfs/xen: implement response_buffer_size callback hw/9pfs: cap Treaddir allocation (CVE-2026-9238)

 hw/9pfs/9p.c               | 34 ++++++++++++++++++++++++++++++++--
 hw/9pfs/9p.h               |  2 ++
 hw/9pfs/virtio-9p-device.c | 17 +++++++++++++++++
 hw/9pfs/xen-9p-backend.c   | 31 +++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 2 deletions(-)