[PATCH v2 0/5] 9p: bound zero-copy error replies

From: Lianjie Wang

Date: Mon Nov 23 2026 - 15:43:06 EST


With the error reply to a zero-copy request, a virtio-9p device can make
the client read past the posted buffers (patch 1), also with an RLERROR
under 9P2000 and 9P2000.u (patch 2) and with a reply after a fatal
signal (patch 3). Patch 4 fixes a double put of a zero-copy request
interrupted by a fatal signal while waiting for the ring. Patch 5 fixes
an uninitialized value printed in a debug message.

The patches were tested with QEMU modified to send the malformed or slow
replies.

Patches 3 to 5 of v1 are left out in v2, since patch 3 of v1 fixes the
use-after-free on a request returned after the RFLUSH, but puts a freed
request returned after an umount [1], because an umount frees the client
and the requests while the device still holds them. Fixing this entirely
appears to require deferring the destruction of the client to a
workqueue until the device has returned every request, which is costly
and beyond the current scope. Patches 4 and 5 of v1 depend on patch 3,
so these patches may be sent again in a later series.

v2:
- Rebase onto v7.4-rc4.
- Add patch 2 for the RLERROR case raised in the review [2].
- In patch 3, accept a late reply within the part of rc.sdata posted for
the header, as raised in the review [3].
- Add patch 4 for the double put that patch 3 of v1 also fixed.
- Add patch 5 for the uninitialized ecode raised in the review [4].
- Drop patches 3 to 5 of v1.

[1] https://lore.kernel.org/all/179446999129.2199510.15094266003962078465@xxxxxxxxxx/
[2] https://lore.kernel.org/all/179446998758.2199510.14994914047354508278@xxxxxxxxxx/
[3] https://lore.kernel.org/all/179446998948.2199510.3182298225630042557@xxxxxxxxxx/
[4] https://lore.kernel.org/all/sashiko-outbox-206901@xxxxxxxxxx/
v1: https://lore.kernel.org/all/20261109105251.2545764-1-lian@xxxxxxxxxxxxxxxxxx/

Lianjie Wang (5):
9p/virtio: clamp the reply size of a zero-copy request
9p/virtio: move the error string of an RLERROR into rc.sdata
9p: bound the zero-copy reply after a fatal signal
9p/virtio: set REQ_STATUS_SENT after adding a zero-copy request
9p: initialize ecode in p9_check_errors()

net/9p/client.c | 16 ++++++++++++----
net/9p/trans_virtio.c | 15 ++++++++++-----
2 files changed, 22 insertions(+), 9 deletions(-)


base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
--
2.56.1