[PATCH v2 0/2] 9p: handle long directory entry names in readdir

From: Haobin Wu

Date: Wed Sep 16 2026 - 10:03:55 EST


Hi Dominique,

Thanks for the review, and sorry for the delay. Here is v2 with the
changes you and Jan asked for; details below.

A host directory entry whose name is longer than 255 bytes currently
makes 9p's readdir fail with -EIO and hides every entry after it, which
is how this was noticed on WSL (Plan 9 shares of Windows drives).

Patch 1 drops the copy into the fixed 256-byte p9_dirent::d_name and
uses the string p9pdu_vreadf() already allocated, so the listing no
longer aborts.

Patch 2 then skips entries whose name is longer than NAME_MAX instead
of returning them to userspace, as discussed with Dominique and Jan on
v1: the VFS only enforces PATH_MAX in verify_dirent_name(), and nothing
can operate on such a name afterwards anyway.

Changes since v1:
- Use my real name in From/Signed-off-by (Dominique).
- Split into two patches (Dominique).
- Reworded the subject and commit message of patch 1 to describe the
existing readdir path and clarify that no allocation is added
(Dominique).
- New patch 2 skipping entries longer than NAME_MAX (Dominique, Jan).
- Dropped the bouncing sripathik@xxxxxxxxxx address from Cc.

v1: https://lore.kernel.org/all/20260826064819.52523-1-853555@xxxxxxxxx/

Haobin Wu (2):
9p: skip intermediate directory entry name copy in p9dirent_read()
9p: skip directory entries with names longer than NAME_MAX

fs/9p/vfs_dir.c | 17 +++++++++++++----
include/net/9p/client.h | 2 +-
net/9p/protocol.c | 12 ++----------
3 files changed, 16 insertions(+), 15 deletions(-)


base-commit: 028ef9c96e96197026887c0f092424679298aae8
--
2.54.0 (Apple Git-157)