mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Ochs <mochs@nvidia.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Bernd Schubert <bschubert@ddn.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] fuse: do not treat unlimited readdir count as a buffer size
Date: Tue, 28 Apr 2026 22:36:46 +0000	[thread overview]
Message-ID: <B851F08C-3A33-4366-A114-0CC657097B21@nvidia.com> (raw)
In-Reply-To: <CAJfpeguzUDE1gegKA3WXCORZZRQrWCRsKe_sdLKtGHqRd_vyyQ@mail.gmail.com>

> On Apr 28, 2026, at 08:11, Miklos Szeredi <miklos@szeredi.hu> wrote:
> 
> On Tue, 28 Apr 2026 at 04:13, Matthew R. Ochs <mochs@nvidia.com> wrote:
> 
>> For virtiofs, the output kvec is included in the request bounce buffer
>> allocated by copy_args_to_argbuf():
>> 
>>  req->argbuf = kmalloc(len, GFP_ATOMIC);
> 
> Ugh.   The real bug here is inappropriate use of the bounce buffer.
> fuse_readdir_uncached() should instead supply an array of pages.
> 
> It's a little more complicated, but would fix this properly: overlayfs
> does want to get as much of the directory as possible in one go to be
> most efficient.
> 
> I'd go with vmalloc -> alloc_pages_bulk, then vm_map_ram() before
> parsing the result.
> 

Thanks, that makes sense. I reworked the fix along those lines: uncached
readdir now supplies output pages via out_pages and uses vm_map_ram() only
for the existing parser.

Testing also showed that the request size needs to be capped by
fc->max_write as well as fc->max_pages. fc->max_pages is a page-count
limit, and with a 4K host / 64K guest virtiofsd advertised 124 pages,
which the guest turned into an ~8 MiB READDIR. virtiofsd's byte-sized
payload limit was 1 MiB, so the page-backed version still failed until the
fc->max_write cap was added.

I’ll send out a v2 shortly.


-matt


      reply	other threads:[~2026-04-28 22:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28  2:13 Matthew R. Ochs
2026-04-28 13:11 ` Miklos Szeredi
2026-04-28 22:36   ` Matt Ochs [this message]

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=B851F08C-3A33-4366-A114-0CC657097B21@nvidia.com \
    --to=mochs@nvidia.com \
    --cc=bschubert@ddn.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=stable@vger.kernel.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®