From: The 8472 <kernel@infinite-source.de>
To: The 8472 <kernel@infinite-source.de>,
Miklos Szeredi <miklos@szeredi.hu>,
Antonio SJ Musumeci <trapexit@spawn.link>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: EBADF returned from close() by FUSE
Date: Tue, 23 Apr 2024 23:38:43 +0200 [thread overview]
Message-ID: <d862407f-640a-4fa0-833d-c2fa35eff119@infinite-source.de> (raw)
In-Reply-To: <692a9f0b-9c2b-4850-b8bc-48f09fe41762@infinite-source.de>
On 23-04-2024 15:38, Miklos Szeredi wrote:
> On Tue, 23 Apr 2024 at 15:24, Antonio SJ Musumeci<trapexit@spawn.link> wrote:
>
>> From the write(2) manpage (at least on Ubuntu):
>>
>> "Other errors may occur, depending on the object connected to fd."
>>
>> My argument has been that this note is defacto true generally.
> Yes.
In some places we do rely on error codes having exactly the documented meaning
and no other. E.g. fcntl(..., F_GETFD) failing with EBADF is treated as fatal,
other codes are not.
Or openat(..., O_NOFOLLOW | O_DIRECTORY) returning ENOTDIR is trusted to mean
that the file is in fact not a directory and can be unlinked instead of rmdir'd
>> The specifics of this thread stem from close() returning EBADF to the
>> client app while talking to a FUSE server after the open() succeeded
>> and, from the point of view of the client app, returned a valid file
>> descriptor. Sounds like a bug in the FUSE server rather than something
>> FUSE itself needs to worry about.
> Return value from close is ignored in 99% of cases. It is quite hard
> to imagine this making real difference to an application. The basic
> philosophy of the linux kernel is pragmatism: if it matters in a real
> world use case, then we care, otherwise we don't. I don't think a
> server returning EBADF matters in real life, but if it is, then we do
> need to take care of it.
Current Rust versions unwind if closedir() is not successful since
directories aren't writable and aren't expected to have writeback
errors. That's what lead to this thread.
If that had returned an EIO that would have been annoying but
would clearly point at unreliable storage. If it returns
EBADF that is more concerning because it could be a double-close or
something similar within the process clobbering FDs.
>> This is not unlike a recent complaint that when link() is not
>> implemented libfuse returns ENOSYS rather than EPERM. As I pointed out
>> in that situation EPERM is not universally defined as meaning "not
>> implemented by filesystem" like used in Linux. Doesn't mean it isn't
>> used (I didn't check) but it isn't defined as such in docs.
> ENOSYS is a good example where fuse does need to filter out errors,
> since applications do interpret ENOSYS as "kernel doesn't implement
> this syscall" and fuse actually uses ENOSYS for a different purpose.
Yes, we use ENOSYS a lot for feature detection. Bogus ones would result
result in loss of performance and minor functionality.
Due to old docker seccomp filters returning EPERM instead of ENOSYS
on filtered syscalls we sometimes also have to treat EPERM like ENOSYS
on syscalls where EPERM is not documented as one of the valid return codes.
Also, "not universally defined" is not relevant, we consult a platform's
manpages to understand platform-specific behavior, not just the posix ones.
So if linux implements its fuse client in a way that propagates arbitrary
error codes to syscalls for which the linux-specific documentation says that only
a certain set of error codes with specific meanings would be returned then
either the documentation is wrong or those errors should be mangled before
they bubble up to the syscall.
next prev parent reply other threads:[~2024-04-23 21:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-18 22:10 EBADF returned from close() by FUSE The 8472
2024-04-19 3:30 ` Antonio SJ Musumeci
2024-04-19 6:55 ` The 8472
[not found] ` <8c7552b1-f371-4a75-98cc-f2c89816becb@spawn.link>
2024-04-19 18:18 ` The 8472
2024-04-19 20:07 ` Antonio SJ Musumeci
2024-04-19 20:45 ` The 8472
2024-04-19 21:29 ` Antonio SJ Musumeci
2024-04-19 22:04 ` The 8472
2024-04-19 22:47 ` Antonio SJ Musumeci
2024-04-19 23:04 ` The 8472
2024-04-23 12:46 ` Miklos Szeredi
2024-04-23 13:24 ` Antonio SJ Musumeci
2024-04-23 13:38 ` Miklos Szeredi
[not found] ` <692a9f0b-9c2b-4850-b8bc-48f09fe41762@infinite-source.de>
2024-04-23 21:38 ` The 8472 [this message]
2024-04-26 8:52 ` Miklos Szeredi
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=d862407f-640a-4fa0-833d-c2fa35eff119@infinite-source.de \
--to=kernel@infinite-source.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=trapexit@spawn.link \
/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).