From: Andrey Albershteyn <aalbersh@redhat.com>
To: "Amir Goldstein" <amir73il@gmail.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Casey Schaufler" <casey@schaufler-ca.com>,
"Christian Brauner" <brauner@kernel.org>,
"Jan Kara" <jack@suse.cz>, "Pali Rohár" <pali@kernel.org>,
"Paul Moore" <paul@paul-moore.com>
Cc: linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
selinux@vger.kernel.org,
Andrey Albershteyn <aalbersh@kernel.org>
Subject: [PATCH v6 4/6] fs: make vfs_fileattr_[get|set] return -EOPNOSUPP
Date: Mon, 30 Jun 2025 18:20:14 +0200 [thread overview]
Message-ID: <20250630-xattrat-syscall-v6-4-c4e3bc35227b@kernel.org> (raw)
In-Reply-To: <20250630-xattrat-syscall-v6-0-c4e3bc35227b@kernel.org>
Future patches will add new syscalls which use these functions. As
this interface won't be used for ioctls only, the EOPNOSUPP is more
appropriate return code.
This patch converts return code from ENOIOCTLCMD to EOPNOSUPP for
vfs_fileattr_get and vfs_fileattr_set. To save old behavior translate
EOPNOSUPP back for current users - overlayfs, encryptfs and fs/ioctl.c.
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
fs/ecryptfs/inode.c | 8 +++++++-
fs/file_attr.c | 12 ++++++++++--
fs/overlayfs/inode.c | 2 +-
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 493d7f194956..a55c1375127f 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1126,7 +1126,13 @@ static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,
static int ecryptfs_fileattr_get(struct dentry *dentry, struct fileattr *fa)
{
- return vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);
+ int rc;
+
+ rc = vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);
+ if (rc == -EOPNOTSUPP)
+ rc = -ENOIOCTLCMD;
+
+ return rc;
}
static int ecryptfs_fileattr_set(struct mnt_idmap *idmap,
diff --git a/fs/file_attr.c b/fs/file_attr.c
index be62d97cc444..4e85fa00c092 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -79,7 +79,7 @@ int vfs_fileattr_get(struct dentry *dentry, struct fileattr *fa)
int error;
if (!inode->i_op->fileattr_get)
- return -ENOIOCTLCMD;
+ return -EOPNOTSUPP;
error = security_inode_file_getattr(dentry, fa);
if (error)
@@ -229,7 +229,7 @@ int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
int err;
if (!inode->i_op->fileattr_set)
- return -ENOIOCTLCMD;
+ return -EOPNOTSUPP;
if (!inode_owner_or_capable(idmap, inode))
return -EPERM;
@@ -271,6 +271,8 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
int err;
err = vfs_fileattr_get(file->f_path.dentry, &fa);
+ if (err == -EOPNOTSUPP)
+ err = -ENOIOCTLCMD;
if (!err)
err = put_user(fa.flags, argp);
return err;
@@ -292,6 +294,8 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)
fileattr_fill_flags(&fa, flags);
err = vfs_fileattr_set(idmap, dentry, &fa);
mnt_drop_write_file(file);
+ if (err == -EOPNOTSUPP)
+ err = -ENOIOCTLCMD;
}
}
return err;
@@ -304,6 +308,8 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
int err;
err = vfs_fileattr_get(file->f_path.dentry, &fa);
+ if (err == -EOPNOTSUPP)
+ err = -ENOIOCTLCMD;
if (!err)
err = copy_fsxattr_to_user(&fa, argp);
@@ -324,6 +330,8 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)
if (!err) {
err = vfs_fileattr_set(idmap, dentry, &fa);
mnt_drop_write_file(file);
+ if (err == -EOPNOTSUPP)
+ err = -ENOIOCTLCMD;
}
}
return err;
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 6f0e15f86c21..096d44712bb1 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -721,7 +721,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa)
return err;
err = vfs_fileattr_get(realpath->dentry, fa);
- if (err == -ENOIOCTLCMD)
+ if (err == -EOPNOTSUPP)
err = -ENOTTY;
return err;
}
--
2.47.2
next prev parent reply other threads:[~2025-06-30 16:20 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 16:20 [PATCH v6 0/6] fs: introduce file_getattr and file_setattr syscalls Andrey Albershteyn
2025-06-30 16:20 ` [PATCH v6 1/6] fs: split fileattr related helpers into separate file Andrey Albershteyn
2025-07-01 5:39 ` Amir Goldstein
2025-07-01 12:38 ` Jan Kara
2025-07-01 18:13 ` Darrick J. Wong
2025-06-30 16:20 ` [PATCH v6 2/6] lsm: introduce new hooks for setting/getting inode fsxattr Andrey Albershteyn
2025-07-01 12:39 ` Jan Kara
2025-07-01 18:18 ` Darrick J. Wong
2025-07-02 8:47 ` Andrey Albershteyn
2025-06-30 16:20 ` [PATCH v6 3/6] selinux: implement inode_file_[g|s]etattr hooks Andrey Albershteyn
2025-06-30 16:20 ` Andrey Albershteyn [this message]
2025-06-30 18:05 ` [PATCH v6 4/6] fs: make vfs_fileattr_[get|set] return -EOPNOSUPP Pali Rohár
2025-07-01 6:05 ` Amir Goldstein
2025-07-01 12:51 ` Jan Kara
2025-07-01 14:16 ` Amir Goldstein
2025-07-01 12:52 ` Jan Kara
2025-07-01 18:18 ` Darrick J. Wong
2025-06-30 16:20 ` [PATCH v6 5/6] fs: prepare for extending file_get/setattr() Andrey Albershteyn
2025-07-01 13:06 ` Jan Kara
2025-07-01 18:31 ` Darrick J. Wong
2025-07-01 19:27 ` Amir Goldstein
2025-07-01 19:40 ` Darrick J. Wong
2025-07-01 19:54 ` Pali Rohár
2025-07-02 7:03 ` Amir Goldstein
2025-07-02 9:48 ` Amir Goldstein
2025-07-02 12:24 ` Christian Brauner
2025-06-30 16:20 ` [PATCH v6 6/6] fs: introduce file_getattr and file_setattr syscalls Andrey Albershteyn
2025-07-01 12:34 ` Christian Brauner
2025-07-02 9:13 ` Amir Goldstein
2025-07-01 13:24 ` Jan Kara
2025-07-01 18:43 ` Darrick J. Wong
2025-07-01 18:54 ` Pali Rohár
2025-07-01 19:08 ` Darrick J. Wong
2025-07-01 19:17 ` Pali Rohár
2025-07-02 12:40 ` Christian Brauner
2025-07-02 13:43 ` Amir Goldstein
2025-07-02 18:37 ` Darrick J. Wong
2025-07-03 8:28 ` Christian Brauner
2025-07-03 8:42 ` Amir Goldstein
2025-07-03 8:46 ` Christian Brauner
2025-07-03 22:35 ` Darrick J. Wong
2025-07-01 6:11 ` [PATCH v6 0/6] " Amir Goldstein
2025-07-01 12:29 ` Christian Brauner
2025-07-07 12:05 ` Andrey Albershteyn
2025-07-07 12:19 ` Christian Brauner
2025-07-07 12:27 ` Andrey Albershteyn
2025-07-07 12:19 ` 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=20250630-xattrat-syscall-v6-4-c4e3bc35227b@kernel.org \
--to=aalbersh@redhat.com \
--cc=aalbersh@kernel.org \
--cc=amir73il@gmail.com \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=casey@schaufler-ca.com \
--cc=jack@suse.cz \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=pali@kernel.org \
--cc=paul@paul-moore.com \
--cc=selinux@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).