[PATCH v2 2/5] 9p/virtio: move the error string of an RLERROR into rc.sdata

From: Lianjie Wang

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


p9_check_errors() parses an error string from both RERROR and RLERROR
when the protocol is not 9P2000.L, but p9_virtio_zc_request() calls
handle_rerror() only for RERROR. The error string of an RLERROR reply to
a zero-copy request is therefore left in the reply pages while the reply
size still includes it, so p9_check_errors() can parse the string past
the end of rc.sdata:

BUG: KASAN: slab-out-of-bounds in p9pdu_readf+0x151e/0x1c50
Read of size 8179 at addr ffff888004b4c009 by task ls/155
Call Trace:
p9pdu_readf+0x151e/0x1c50
p9_check_errors+0x23d/0x510
p9_client_zc_rpc+0x4f0/0x970
p9_client_read_once+0x237/0x6c0
p9_client_read+0x9d/0x140
v9fs_dir_readdir+0x2ea/0x730

Fix this by calling handle_rerror() for both error replies.

This patch is assisted by Claude Opus 5.5.

Reported-by: Sashiko <netdev-bot+sashiko@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/179446998758.2199510.14994914047354508278@xxxxxxxxxx/
Fixes: f615625a44c4 ("9p: handling Rerror without copy_from_iter_full()")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lianjie Wang <lian@xxxxxxxxxxxxxxxxxx>
---
v2:
- New patch.

net/9p/trans_virtio.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 53046668c16b1..8d9555e64490e 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -541,8 +541,9 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
// The device may report more than the buffers we posted
req->rc.size = umin(req->rc.size, in_hdr_len + inlen);

- // RERROR needs reply (== error string) in static data
- if (unlikely(req->rc.sdata[4] == P9_RERROR))
+ // RERROR/RLERROR needs reply (== error string) in static data
+ if (unlikely(req->rc.sdata[4] == P9_RERROR ||
+ req->rc.sdata[4] == P9_RLERROR))
handle_rerror(req, in_hdr_len, offs, in_pages);
}

--
2.56.1