mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Schoenebeck <linux_oss@crudebyte.com>
To: ericvh@kernel.org, lucho@ionkov.net, asmadeus@codewreck.org,
	v9fs@lists.linux.dev, Haobin Wu <853555@gmail.com>
Cc: jack@suse.cz, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org,
	aneesh.kumar@linux.vnet.ibm.com, willy@infradead.org,
	dhowells@redhat.com, viro@zeniv.linux.org.uk, brauner@kernel.org
Subject: Re: [PATCH v3 1/3] 9p: skip intermediate directory entry name copy in p9dirent_read()
Date: Fri, 18 Sep 2026 13:07:10 +0200	[thread overview]
Message-ID: <12972173.O9o76ZdvQC@weasel> (raw)
In-Reply-To: <20260918024851.51229-2-853555@gmail.com>

On Friday, 18 September 2026 04:48:49 CEST Haobin Wu wrote:
> v9fs_dir_readdir_dotl() decodes each entry of a Rreaddir reply with
> p9dirent_read(), which parses it through p9pdu_readf("Qqbs"). The 's'
> conversion in p9pdu_vreadf() already allocates a NUL-terminated copy
> of the name from the wire buffer; p9dirent_read() then strscpy()s that
> copy into the fixed 256-byte p9_dirent::d_name and frees the original.
> 
> The wire format carries the name length in 16 bits, so a name longer
> than 255 bytes is valid on the wire and may well be valid on the
> server's filesystem, but it makes strscpy() return -E2BIG.
> v9fs_dir_readdir_dotl() turns that into -EIO and aborts getdents64(),
> so every entry after the long one disappears from the listing.
> 
> Drop the second copy: keep the string allocated by p9pdu_vreadf() in
> p9_dirent and let v9fs_dir_readdir_dotl(), its only user, free it once
> dir_emit() has consumed it. p9_dirent is a short-lived stack object, so
> the string's lifetime does not change.
> 
> Note that the VFS only rejects names of PATH_MAX bytes or more in
> verify_dirent_name(), so after this change a name between NAME_MAX and
> PATH_MAX is returned by getdents64() even though any later lookup on it
> fails with -ENAMETOOLONG. The next patch skips such entries.
> 
> Fixes: 7751bdb3a095 ("9p: readdir implementation for 9p2000.L")
> Closes: https://github.com/microsoft/WSL/issues/41192
> Signed-off-by: Haobin Wu <853555@gmail.com>

Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>

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



  reply	other threads:[~2026-09-18 11:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18  2:48 [PATCH v3 0/3] 9p: handle long directory entry names in readdir Haobin Wu
2026-09-18  2:48 ` [PATCH v3 1/3] 9p: skip intermediate directory entry name copy in p9dirent_read() Haobin Wu
2026-09-18 11:07   ` Christian Schoenebeck [this message]
2026-09-18  2:48 ` [PATCH v3 2/3] 9p: skip directory entries with names longer than NAME_MAX Haobin Wu
2026-09-18 11:09   ` Christian Schoenebeck
2026-09-18  2:48 ` [PATCH v3 3/3] 9p: skip over-long directory entry names for legacy 9p2000 too Haobin Wu
2026-09-18 12:08   ` Christian Schoenebeck
2026-09-22  8:34     ` Dominique Martinet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12972173.O9o76ZdvQC@weasel \
    --to=linux_oss@crudebyte.com \
    --cc=853555@gmail.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=asmadeus@codewreck.org \
    --cc=brauner@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=edumazet@google.com \
    --cc=ericvh@kernel.org \
    --cc=horms@kernel.org \
    --cc=jack@suse.cz \
    --cc=kuba@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=v9fs@lists.linux.dev \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®