From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
Jan Kara <jack@suse.cz>, Jiri Slaby <jirislaby@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Andrey Albershteyn <aalbersh@kernel.org>
Subject: Re: [PATCH 2/2] fs: return EOPNOTSUPP from file_setattr/file_getattr syscalls
Date: Thu, 9 Oct 2025 10:20:41 -0700 [thread overview]
Message-ID: <20251009172041.GA6174@frogsfrogsfrogs> (raw)
In-Reply-To: <20251008-eopnosupp-fix-v1-2-5990de009c9f@kernel.org>
On Wed, Oct 08, 2025 at 02:44:18PM +0200, Andrey Albershteyn wrote:
> These syscalls call to vfs_fileattr_get/set functions which return
> ENOIOCTLCMD if filesystem doesn't support setting file attribute on an
> inode. For syscalls EOPNOTSUPP would be more appropriate return error.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
> ---
> fs/file_attr.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/file_attr.c b/fs/file_attr.c
> index 460b2dd21a85..5e3e2aba97b5 100644
> --- a/fs/file_attr.c
> +++ b/fs/file_attr.c
> @@ -416,6 +416,8 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename,
> }
>
> error = vfs_fileattr_get(filepath.dentry, &fa);
> + if (error == -ENOIOCTLCMD)
Hrm. Back in 6.17, XFS would return ENOTTY if you called ->fileattr_get
on a special file:
int
xfs_fileattr_get(
struct dentry *dentry,
struct file_kattr *fa)
{
struct xfs_inode *ip = XFS_I(d_inode(dentry));
if (d_is_special(dentry))
return -ENOTTY;
...
}
Given that there are other fileattr_[gs]et implementations out there
that might return ENOTTY (e.g. fuse servers and other externally
maintained filesystems), I think both syscall functions need to check
for that as well:
if (error == -ENOIOCTLCMD || error == -ENOTTY)
return -EOPNOTSUPP;
--D
> + error = -EOPNOTSUPP;
> if (error)
> return error;
>
> @@ -483,6 +485,8 @@ SYSCALL_DEFINE5(file_setattr, int, dfd, const char __user *, filename,
> if (!error) {
> error = vfs_fileattr_set(mnt_idmap(filepath.mnt),
> filepath.dentry, &fa);
> + if (error == -ENOIOCTLCMD)
> + error = -EOPNOTSUPP;
> mnt_drop_write(filepath.mnt);
> }
>
>
> --
> 2.51.0
>
>
next prev parent reply other threads:[~2025-10-09 17:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-08 12:44 [PATCH 0/2] Fix to EOPNOTSUPP double conversion in ioctl_setflags() Andrey Albershteyn
2025-10-08 12:44 ` [PATCH 1/2] Revert "fs: make vfs_fileattr_[get|set] return -EOPNOTSUPP" Andrey Albershteyn
2025-10-08 12:44 ` [PATCH 2/2] fs: return EOPNOTSUPP from file_setattr/file_getattr syscalls Andrey Albershteyn
2025-10-08 13:23 ` Arnd Bergmann
2025-10-08 13:30 ` Jan Kara
2025-10-09 17:20 ` Darrick J. Wong [this message]
2025-10-10 10:05 ` Andrey Albershteyn
2025-10-10 11:45 ` Christian Brauner
2025-10-10 11:47 ` [PATCH 0/2] Fix to EOPNOTSUPP double conversion in ioctl_setflags() Christian Brauner
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=20251009172041.GA6174@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@kernel.org \
--cc=aalbersh@redhat.com \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=jirislaby@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@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;
as well as URLs for NNTP newsgroup(s).