From: Antonio SJ Musumeci <trapexit@spawn.link>
To: Amir Goldstein <amir73il@gmail.com>
Cc: fuse-devel <fuse-devel@lists.sourceforge.net>,
Miklos Szeredi <miklos@szeredi.hu>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Bernd Schubert <bernd.schubert@fastmail.fm>
Subject: Re: [fuse-devel] Proxmox + NFS w/ exported FUSE = EIO
Date: Wed, 07 Feb 2024 00:08:16 +0000 [thread overview]
Message-ID: <764a49b0-9a82-4042-8e03-10219b152e77@spawn.link> (raw)
In-Reply-To: <CAOQ4uxhek5ytdN8Yz2tNEOg5ea4NkBb4nk0FGPjPk_9nz-VG3g@mail.gmail.com>
On 2/6/24 00:53, Amir Goldstein wrote:
> On Tue, Feb 6, 2024 at 4:52 AM Antonio SJ Musumeci <trapexit@spawn.link> wrote:
>> Hi,
>>
>> Anyone have users exporting a FUSE filesystem over NFS? Particularly
>> from Proxmox (recent release, kernel 6.5.11)? I've gotten a number of
>> reports recently from individuals who have such a setup and after some
>> time (not easily reproducible, seems usually after software like Plex or
>> Jellyfin do a scan of media or a backup process) starts returning EIO
>> errors. Not just from NFS but also when trying to access the FUSE mount
>> as well. One person noted that they had moved from Ubuntu 18.04 (kernel
>> 4.15.0) to Proxmox and on Ubuntu had no problems with otherwise the same
>> settings.
>>
>> I've not yet been able to reproduced this issue myself but wanted to see
>> if anyone else has run into this. As far as I can tell from what users
>> have reported the FUSE server is still running but isn't receiving most
>> requests. I do see evidence of statfs calls coming through but nothing
>> else. Though the straces I've received typically are after the issues start.
>>
>> In an effort to rule out the FUSE server... is there anything the server
>> could do to cause the kernel to return EIO and not forward anything but
>> statfs? Doesn't seem to matter if direct_io is enabled or attr/entry
>> caching is used.
>>
> This could be the outcome of commit 15db16837a35 ("fuse: fix illegal
> access to inode with reused nodeid") in kernel v5.14.
>
> It is not an unintended regression - this behavior replaces what would
> have been a potentially severe security violation with an EIO error.
>
> As the commit says:
> "...With current code, this situation will not be detected and an old fuse
> dentry that used to point to an older generation real inode, can be used to
> access a completely new inode, which should be accessed only via the new
> dentry."
>
> I have made this fix after seeing users get the content of another
> file from the one that they opened in NFS!
>
> libfuse commit 10ecd4f ("test/test_syscalls.c: check unlinked testfiles
> at the end of the test") reproduces this problem in a test.
> This test does not involve NFS export, but NFS export has higher
> likelihood of exposing this issue.
>
> I wonder if the FUSE filesystems that report the errors have
> FUSE_EXPORT_SUPPORT capability?
> Not that this capability guarantees anything wrt to this issue.
>
> IMO, the root of all evil wrt NFS+FUSE is that LOOKUP is by ino
> without generation with FUSE_EXPORT_SUPPORT, but worse
> is that FUSE does not even require FUSE_EXPORT_SUPPORT
> capability to export to NFS, but this is legacy FUSE behavior and
> I am sure that many people export FUSE filesystems, as your
> report proves.
>
> There is now a proposal for opt-out of NFS export:
> https://lore.kernel.org/linux-fsdevel/20240126072120.71867-1-jefflexu@linux.alibaba.com/
> so there will be a way for a FUSE filesystem to prevent misuse.
>
> Some practical suggestions for users running existing FUSE filesystems:
>
> - Never export a FUSE filesystem with a fixed fsid
> - Everytime one wants to export a FUSE filesystem generate
> a oneshot fsid/uuid to use in exportfs
> - Then restarting/re-exporting the FUSE filesystem will result in
> ESTALE errors on NFS client, but not security violations and not EIO
> errors
> - This does not give full guarantee, unlinked inodes could still result
> in EIO errors, as the libfuse test demonstrates
> - The situation with NFSv4 is slightly better than with NFSv3, because
> with NFSv3, an open file in the client does not keep the FUSE file
> open and increases the chance of evicted FUSE inode for an open
> NFS file
>
> Thanks,
> Amir.
Thank you Amir for such a detailed response. I'll look into this further
but a few questions. To answer your question: yes, the server is setting
EXPORT_SUPPORT.
1. The expected behavior, if the above situation occurred, is that the
whole of the mount would return EIO? All requests going forward? What
about FUSE_STATFS? From what I saw that was coming through.
2. Regarding the tests. I downloaded the latest libfuse, compiled, and
ran test_syscalls against the FUSE server. I get no failures when
running `./test_syscalls /mnt/fusemount :/mnt/ext4mount -u` or
`./test_syscalls /mnt/fusemount -u` where ext4mount is the underlying
filesystem and fusemount is the FUSE server's. No error is reported. A
strace shows the fstat returning ESTALE at the end but the tests all
pass. The mount continues to work after running the test. This is on
kernel 6.5.0. Is that expected? It sounds from your description that I
should be seeing EIOs somewhere.
3. Thank you for the "practical suggestions". I will compare them to
what my users are doing... but are there specific guidelines somewhere
for building a FUSE server to ensure NFS export can be supported? This
topic has had limited details available over the years and I/users have
had odd behaviors at times that were unclear of the cause. Like this
situation or when NFS somehow triggered a request for '..' of the root
nodeid (1). Some questions that come to mind: is the generation strictly
necessary (practically) for things to work so long as nodeid is unique
during a session (64bit nodeid space can last a long time)? Is there
possibility of conflict if multiple fuse servers used the same
nodeid//gen pairs at the same time? To what degree does the inode value
matter? Should old node/gen pairs be kept around forever as noforget
libfuse option suggests for NFS? Perhaps some of this is obvious but
given changes to FUSE over time and the differences between kernel and
userspace fs experiences it would be nice to have some of these more
niche/complicated situations better flushed out in the official docs.
Thanks again.
next prev parent reply other threads:[~2024-02-07 0:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d997c02b-d5ef-41f8-92b6-8c6775899388@spawn.link>
2024-02-06 6:53 ` [fuse-devel] Proxmox + NFS w/ exported FUSE = EIO Amir Goldstein
2024-02-07 0:08 ` Antonio SJ Musumeci [this message]
2024-02-07 7:24 ` Amir Goldstein
[not found] ` <b9cec6b7-0973-4d61-9bef-120e3c4654d7@spawn.link>
[not found] ` <CAOQ4uxgZR4OtCkdrpcDGCK-MqZEHcrx+RY4G94saqaXVkL4cKA@mail.gmail.com>
2024-02-18 0:48 ` Antonio SJ Musumeci
2024-02-19 11:36 ` Bernd Schubert
2024-02-19 19:05 ` Antonio SJ Musumeci
2024-02-19 19:17 ` Bernd Schubert
2024-02-19 19:38 ` Miklos Szeredi
2024-02-19 19:54 ` Antonio SJ Musumeci
2024-02-20 8:35 ` Miklos Szeredi
2024-02-20 8:47 ` Miklos Szeredi
2024-02-22 1:25 ` Antonio SJ Musumeci
2024-02-22 11:09 ` Miklos Szeredi
2024-02-25 0:18 ` Antonio SJ Musumeci
2024-02-25 20:58 ` Antonio SJ Musumeci
2024-02-28 13:06 ` Miklos Szeredi
2024-02-28 13:16 ` Bernd Schubert
2024-02-28 14:14 ` Miklos Szeredi
2024-02-28 16:03 ` Miklos Szeredi
2024-02-19 19:55 ` Bernd Schubert
2024-02-19 19:58 ` Miklos Szeredi
2024-02-19 21:14 ` Bernd Schubert
2024-02-19 23:22 ` Bernd Schubert
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=764a49b0-9a82-4042-8e03-10219b152e77@spawn.link \
--to=trapexit@spawn.link \
--cc=amir73il@gmail.com \
--cc=bernd.schubert@fastmail.fm \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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;
as well as URLs for NNTP newsgroup(s).