Thread (8 messages) 8 messages, 3 authors, 15d ago

Re: [PATCH v3 2/3] 9p: skip directory entries with names longer than NAME_MAX

flat view

From: Christian Schoenebeck <linux_oss@crudebyte.com>
Date: 2026-09-18 11:09:32
Also in: linux-fsdevel, lkml, v9fs

On Friday, 18 September 2026 04:48:50 CEST Haobin Wu wrote:
The 9p wire format carries directory entry names of up to 65535 bytes
and nothing on the client checks them against NAME_MAX. Since the
previous patch, v9fs_dir_readdir_dotl() passes such names straight to
dir_emit(), and the VFS only rejects names of PATH_MAX bytes or more in
verify_dirent_name(), as -EIO, which again fails the whole getdents64()
call.

A name between NAME_MAX and PATH_MAX is therefore returned to userspace
even though every later operation on it fails with -ENAMETOOLONG, and
POSIX requires readdir() to only return components of at most NAME_MAX
bytes. Nothing can use such an entry, so skip it instead of returning it
or failing the listing, reusing the strlen() result that was already
computed for dir_emit(). Log the skipped entry at P9_DEBUG_ERROR, the
same level as the strscpy() failure message this replaces.

Suggested-by: Dominique Martinet <asmadeus@codewreck.org>
Link: https://lore.kernel.org/all/vz5bum547fqyxf5z4m3x7tuqkuq52jlopm65t7hvynqeulh7i3@2t4wnhfxs7qv/ (local) 
Signed-off-by: Haobin Wu <redacted>
Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
quoted hunk ↗ jump to hunk
---
 fs/9p/vfs_dir.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help