Re: [PATCH v3 2/3] 9p: skip directory entries with names longer than NAME_MAX
Christian Schoenebeck <[email protected]>
| Newsgroups | org.kernel.vger.netdev,dev.linux.lists.v9fs,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <6304983.lOV4Wx5bFT@weasel> |
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 <[email protected]> > Link: https://lore.kernel.org/all/vz5bum547fqyxf5z4m3x7tuqkuq52jlopm65t7hvynqeulh7i3@2t4wnhfxs7qv/ > Signed-off-by: Haobin Wu <[email protected]> Reviewed-by: Christian Schoenebeck <[email protected]> > --- > fs/9p/vfs_dir.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-)