new kAPI for FS_IOC_[GS]ETFLAGS/FS_IOC_FS[GS]ETXATTR
Subsystems (19)
v2 cover new kAPI for FS_IOC_[GS]ETFLAGS/FS_IOC_FS[GS]ETXATTR
Hi Al,
See 01/18 for the details.
Can you please apply this series? Or at least the core part, so that the fs parts can go independently?
Christoph, you were positive on the RFC version but didn't comment on the full implementation. Can you please review?
Changes since v1:
- rebased on 5.12-rc1 (mnt_userns churn)
- fixed LSM hook on overlayfs
Git tree is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git#miscattr_v2
Thanks,
Miklos
---
Miklos Szeredi (18):
vfs: add miscattr ops
ecryptfs: stack miscattr ops
ovl: stack miscattr ops
btrfs: convert to miscattr
ext2: convert to miscattr
ext4: convert to miscattr
f2fs: convert to miscattr
gfs2: convert to miscattr
orangefs: convert to miscattr
xfs: convert to miscattr
efivars: convert to miscattr
hfsplus: convert to miscattr
jfs: convert to miscattr
nilfs2: convert to miscattr
ocfs2: convert to miscattr
reiserfs: convert to miscattr
ubifs: convert to miscattr
vfs: remove unused ioctl helpers
Documentation/filesystems/locking.rst | 5 + Documentation/filesystems/vfs.rst | 15 ++ fs/btrfs/ctree.h | 3 + fs/btrfs/inode.c | 4 + fs/btrfs/ioctl.c | 249 ++++--------------- fs/ecryptfs/inode.c | 22 ++ fs/efivarfs/file.c | 77 ------ fs/efivarfs/inode.c | 44 ++++ fs/ext2/ext2.h | 7 +- fs/ext2/file.c | 2 + fs/ext2/ioctl.c | 88 +++---- fs/ext2/namei.c | 2 + fs/ext4/ext4.h | 12 +- fs/ext4/file.c | 2 + fs/ext4/ioctl.c | 210 ++++------------ fs/ext4/namei.c | 2 + fs/f2fs/f2fs.h | 3 + fs/f2fs/file.c | 213 +++-------------- fs/f2fs/namei.c | 2 + fs/gfs2/file.c | 57 ++--- fs/gfs2/inode.c | 4 + fs/gfs2/inode.h | 3 + fs/hfsplus/dir.c | 2 + fs/hfsplus/hfsplus_fs.h | 14 +- fs/hfsplus/inode.c | 54 +++++ fs/hfsplus/ioctl.c | 84 ------- fs/inode.c | 87 ------- fs/ioctl.c | 329 ++++++++++++++++++++++++++ fs/jfs/file.c | 6 +- fs/jfs/ioctl.c | 105 +++----- fs/jfs/jfs_dinode.h | 7 - fs/jfs/jfs_inode.h | 4 +- fs/jfs/namei.c | 6 +- fs/nilfs2/file.c | 2 + fs/nilfs2/ioctl.c | 61 ++--- fs/nilfs2/namei.c | 2 + fs/nilfs2/nilfs.h | 3 + fs/ocfs2/file.c | 2 + fs/ocfs2/ioctl.c | 59 ++--- fs/ocfs2/ioctl.h | 3 + fs/ocfs2/namei.c | 3 + fs/ocfs2/ocfs2_ioctl.h | 8 - fs/orangefs/file.c | 79 ------- fs/orangefs/inode.c | 50 ++++ fs/overlayfs/dir.c | 2 + fs/overlayfs/inode.c | 77 ++++++ fs/overlayfs/overlayfs.h | 3 + fs/reiserfs/file.c | 2 + fs/reiserfs/ioctl.c | 121 +++++----- fs/reiserfs/namei.c | 2 + fs/reiserfs/reiserfs.h | 7 +- fs/reiserfs/super.c | 2 +- fs/ubifs/dir.c | 2 + fs/ubifs/file.c | 2 + fs/ubifs/ioctl.c | 74 +++--- fs/ubifs/ubifs.h | 3 + fs/xfs/libxfs/xfs_fs.h | 4 - fs/xfs/xfs_ioctl.c | 316 +++++++------------------ fs/xfs/xfs_ioctl.h | 11 + fs/xfs/xfs_ioctl32.c | 2 - fs/xfs/xfs_ioctl32.h | 2 - fs/xfs/xfs_iops.c | 7 + include/linux/fs.h | 16 +- include/linux/miscattr.h | 53 +++++ 64 files changed, 1170 insertions(+), 1534 deletions(-) create mode 100644 include/linux/miscattr.h
Signature · 1 line
2.30.2
PATCH v2 1/18 vfs: add miscattr ops
There's a substantial amount of boilerplate in filesystems handling FS_IOC_[GS]ETFLAGS/ FS_IOC_FS[GS]ETXATTR ioctls.
Also due to userspace buffers being involved in the ioctl API this is difficult to stack, as shown by overlayfs issues related to these ioctls.
Introduce a new internal API named "miscattr" (fsxattr can be confused with xattr, xflags is inappropriate, since this is more than just flags).
There's significant overlap between flags and xflags and this API handles the conversions automatically, so filesystems may choose which one to use.
In ->miscattr_get() a hint is provided to the filesystem whether flags or xattr are being requested by userspace, but in this series this hint is ignored by all filesystems, since generating all the attributes is cheap.
If a filesystem doesn't implemement the miscattr API, just fall back to f_op->ioctl(). When all filesystems are converted, the fallback can be removed.
32bit compat ioctls are now handled by the generic code as well.
--- Documentation/filesystems/locking.rst | 5 + Documentation/filesystems/vfs.rst | 15 ++ fs/ioctl.c | 329 ++++++++++++++++++++++++++ include/linux/fs.h | 4 + include/linux/miscattr.h | 53 +++++ 5 files changed, 406 insertions(+) create mode 100644 include/linux/miscattr.h
Documentation/filesystems/locking.rst +5 -0
@@ -80,6 +80,9 @@ prototypes:: struct file *, unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct inode *, struct dentry *, umode_t); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); locking rules: all may block
@@ -107,6 +110,8 @@ fiemap: no update_time: no atomic_open: shared (exclusive if O_CREAT is set in open flags) tmpfile: no +miscattr_get: no or exclusive +miscattr_set: exclusive ============ =============================================
Documentation/filesystems/vfs.rst +15 -0
@@ -441,6 +441,9 @@ As of kernel 2.6.22, the following members are defined: unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct user_namespace *, struct inode *, struct dentry *, umode_t); int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); }; Again, all methods are called without any locks being held, unless
@@ -588,6 +591,18 @@ otherwise noted. atomically creating, opening and unlinking a file in given directory. +``miscattr_get`` + called on ioctl(FS_IOC_GETFLAGS) and ioctl(FS_IOC_FSGETXATTR) to + retrieve miscellaneous filesystem flags and attributes. Also + called before the relevant SET operation to check what is being + changed (in this case with i_rwsem locked exclusive). If unset, + then fall back to f_op->ioctl(). + +``miscattr_set`` + called on ioctl(FS_IOC_SETFLAGS) and ioctl(FS_IOC_FSSETXATTR) to + change miscellaneous filesystem flags and attributes. Callers hold + i_rwsem exclusive. If unset, then fall back to f_op->ioctl(). + The Address Space Object ========================
fs/ioctl.c +329 -0
353 lines not on this page · raw message
include/linux/fs.h +4 -0
@@ -70,6 +70,7 @@ struct fsverity_info;struct fsverity_operations ;struct fs_context ;struct fs_parameter_spec ; +struct miscattr ;extern void __init inode_init (void );extern void __init inode_init_early (void );
@@ -1963,6 +1964,9 @@ struct inode_operations { struct dentry *, umode_t);int (*set_acl)(struct user_namespace *,struct inode *,struct posix_acl *,int ); +int (*miscattr_set)(struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma); +int (*miscattr_get)(struct dentry *dentry,struct miscattr *ma); }____cacheline_aligned ; static inline ssize_t call_read_iter(struct file *file, struct kiocb *kio,
include/linux/miscattr.h new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH v2 01/18] vfs: add miscattr ops
Quoted 70 lines · Miklos Szeredi
There's a substantial amount of boilerplate in filesystems handling FS_IOC_[GS]ETFLAGS/ FS_IOC_FS[GS]ETXATTR ioctls.
Also due to userspace buffers being involved in the ioctl API this is difficult to stack, as shown by overlayfs issues related to these ioctls.
Introduce a new internal API named "miscattr" (fsxattr can be confused with xattr, xflags is inappropriate, since this is more than just flags).
There's significant overlap between flags and xflags and this API handles the conversions automatically, so filesystems may choose which one to use.
In ->miscattr_get() a hint is provided to the filesystem whether flags or xattr are being requested by userspace, but in this series this hint is ignored by all filesystems, since generating all the attributes is cheap.
If a filesystem doesn't implemement the miscattr API, just fall back to
f_op->ioctl(). When all filesystems are converted, the fallback can be removed.32bit compat ioctls are now handled by the generic code as well.
Signed-off-by Miklos Szeredi <[email protected]>--- Documentation/filesystems/locking.rst | 5 + Documentation/filesystems/vfs.rst | 15 ++ fs/ioctl.c | 329 ++++++++++++++++++++++++++ include/linux/fs.h | 4 + include/linux/miscattr.h | 53 +++++ 5 files changed, 406 insertions(+) create mode 100644 include/linux/miscattr.hDocumentation/filesystems/locking.rst +5
-0@@ -80,6 +80,9 @@ prototypes:: struct file *, unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct inode *, struct dentry *, umode_t); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); locking rules: all may block@@ -107,6 +110,8 @@ fiemap: no update_time: no atomic_open: shared (exclusive if O_CREAT is set in open flags) tmpfile: no +miscattr_get: no or exclusive +miscattr_set: exclusive ============ =============================================Documentation/filesystems/vfs.rst +3
-0@@ -441,6 +441,9 @@ As of kernel 2.6.22, the following members are defined: unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct user_namespace *, struct inode *, struct dentry *, umode_t); int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); }; Again, all methods are called without any locks being held, unless
Documentation/filesystems/vfs.rst otherwise noted. · line 594
Quoted 4 lines
Documentation/filesystems/vfs.rst +1
-0@@ -588,6 +591,18 @@ otherwise noted. atomically creating, opening and unlinking a file in given directory. +``miscattr_get``
I wish this wasn't named "misc" because miscellaneous is vague.
fileattr_get, perhaps?
(FWIW I'm not /that/ passionate about starting a naming bikeshed, feel free to ignore.)
Documentation/filesystems/vfs.rst otherwise noted. · line 596
Quoted 2 lines
Documentation/filesystems/vfs.rst +2
-0+ called on ioctl(FS_IOC_GETFLAGS) and ioctl(FS_IOC_FSGETXATTR) to + retrieve miscellaneous filesystem flags and attributes. Also
"...miscellaneous *file* flags and attributes."
Documentation/filesystems/vfs.rst otherwise noted. · line 603
Quoted 7 lines
Documentation/filesystems/vfs.rst +7
-0+ called before the relevant SET operation to check what is being + changed (in this case with i_rwsem locked exclusive). If unset, + then fall back to f_op->ioctl(). + +``miscattr_set`` + called on ioctl(FS_IOC_SETFLAGS) and ioctl(FS_IOC_FSSETXATTR) to + change miscellaneous filesystem flags and attributes. Callers hold
Same here.
Quoted 28 lines
Documentation/filesystems/vfs.rst +2
-0+ i_rwsem exclusive. If unset, then fall back to f_op->ioctl(). + The Address Space Object ========================fs/ioctl.c +8
-0@@ -19,6 +19,9 @@#include <linux/falloc.h> #include <linux/sched/signal.h> #include <linux/fiemap.h> +#include <linux/mount.h> +#include <linux/fscrypt.h> +#include <linux/miscattr.h> #include "internal.h" @@ -657,6 +660,311 @@ static int ioctl_file_dedupe_range(struct file *file,return ret; } +/** +* miscattr_fill_xflags - initialize miscattr with xflags +* @ma: miscattr pointer +* @xflags: FS_XFLAG_* flags +*
fs/ioctl.c static int ioctl_file_dedupe_range(struct file *file, · line 677
Quoted 10 lines
fs/ioctl.c +10
-0+* Set ->fsx_xflags, ->xattr_valid and ->flags (translated xflags). All +* other fields are zeroed. +*/ +void miscattr_fill_xflags (struct miscattr *ma,u32 xflags) +{ +memset (ma,0 ,sizeof (*ma)); + ma->xattr_valid = true; + ma->fsx_xflags = xflags; +if (ma->fsx_xflags &FS_XFLAG_IMMUTABLE ) + ma->flags |=FS_IMMUTABLE_FL ;
I wonder if maintaining redundant sets of flags in the same structure is going to bite us some day.
Quoted 366 lines
fs/ioctl.c +311
-0+if (ma->fsx_xflags &FS_XFLAG_APPEND ) + ma->flags |=FS_APPEND_FL ; +if (ma->fsx_xflags &FS_XFLAG_SYNC ) + ma->flags |=FS_SYNC_FL ; +if (ma->fsx_xflags &FS_XFLAG_NOATIME ) + ma->flags |=FS_NOATIME_FL ; +if (ma->fsx_xflags &FS_XFLAG_NODUMP ) + ma->flags |=FS_NODUMP_FL ; +if (ma->fsx_xflags &FS_XFLAG_DAX ) + ma->flags |=FS_DAX_FL ; +if (ma->fsx_xflags &FS_XFLAG_PROJINHERIT ) + ma->flags |=FS_PROJINHERIT_FL ; +} +EXPORT_SYMBOL (miscattr_fill_xflags); + +/** +* miscattr_fill_flags - initialize miscattr with flags +* @ma: miscattr pointer +* @flags: FS_*_FL flags +* +* Set ->flags, ->flags_valid and ->fsx_xflags (translated flags). +* All other fields are zeroed. +*/ +void miscattr_fill_flags (struct miscattr *ma,u32 flags) +{ +memset (ma,0 ,sizeof (*ma)); + ma->flags_valid = true; + ma->flags = flags; +if (ma->flags &FS_SYNC_FL ) + ma->fsx_xflags |=FS_XFLAG_SYNC ; +if (ma->flags &FS_IMMUTABLE_FL ) + ma->fsx_xflags |=FS_XFLAG_IMMUTABLE ; +if (ma->flags &FS_APPEND_FL ) + ma->fsx_xflags |=FS_XFLAG_APPEND ; +if (ma->flags &FS_NODUMP_FL ) + ma->fsx_xflags |=FS_XFLAG_NODUMP ; +if (ma->flags &FS_NOATIME_FL ) + ma->fsx_xflags |=FS_XFLAG_NOATIME ; +if (ma->flags &FS_DAX_FL ) + ma->fsx_xflags |=FS_XFLAG_DAX ; +if (ma->flags &FS_PROJINHERIT_FL ) + ma->fsx_xflags |=FS_XFLAG_PROJINHERIT ; +} +EXPORT_SYMBOL (miscattr_fill_flags); + +/** +* vfs_miscattr_get - retrieve miscellaneous inode attributes +* @dentry: the object to retrieve from +* @ma: miscattr pointer +* +* Call i_op->miscattr_get() callback, if exists. +* +* Returns 0 on success, or a negative error on failure. +*/ +int vfs_miscattr_get (struct dentry *dentry,struct miscattr *ma) +{ +struct inode *inode =d_inode (dentry); + +if (d_is_special (dentry)) +return -ENOTTY ; + +if (!inode->i_op->miscattr_get) +return -ENOIOCTLCMD ; + +return inode->i_op->miscattr_get (dentry, ma); +} +EXPORT_SYMBOL (vfs_miscattr_get); + +/** +* fsxattr_copy_to_user - copy fsxattr to userspace. +* @ma: miscattr pointer +* @ufa: fsxattr user pointer +* +* Returns 0 on success, or -EFAULT on failure. +*/ +int fsxattr_copy_to_user (const struct miscattr *ma,struct fsxattr __user *ufa) +{ +struct fsxattr fa = { + .fsx_xflags = ma->fsx_xflags, + .fsx_extsize = ma->fsx_extsize, + .fsx_nextents = ma->fsx_nextents, + .fsx_projid = ma->fsx_projid, + .fsx_cowextsize = ma->fsx_cowextsize, + }; + +if (copy_to_user (ufa, &fa,sizeof (fa))) +return -EFAULT ; + +return 0 ; +} +EXPORT_SYMBOL (fsxattr_copy_to_user); + +static int fsxattr_copy_from_user (struct miscattr *ma, +struct fsxattr __user *ufa) +{ +struct fsxattr fa; + +if (copy_from_user (&fa, ufa,sizeof (fa))) +return -EFAULT ; + +miscattr_fill_xflags (ma, fa.fsx_xflags); + ma->fsx_extsize = fa.fsx_extsize; + ma->fsx_nextents = fa.fsx_nextents; + ma->fsx_projid = fa.fsx_projid; + ma->fsx_cowextsize = fa.fsx_cowextsize; + +return 0 ; +} + +/* +* Generic function to check FS_IOC_FSSETXATTR/FS_IOC_SETFLAGS values and reject +* any invalid configurations. +* +* Note: must be called with inode lock held. +*/ +static int miscattr_set_prepare (struct inode *inode, +const struct miscattr *old_ma, +struct miscattr *ma) +{ +int err; + +/* +* The IMMUTABLE and APPEND_ONLY flags can only be changed by +* the relevant capability. +*/ +if ((ma->flags ^ old_ma->flags) & (FS_APPEND_FL |FS_IMMUTABLE_FL ) && + !capable (CAP_LINUX_IMMUTABLE )) +return -EPERM ; + + err =fscrypt_prepare_setflags (inode, old_ma->flags, ma->flags); +if (err) +return err; + +/* +* Project Quota ID state is only allowed to change from within the init +* namespace. Enforce that restriction only if we are trying to change +* the quota ID state. Everything else is allowed in user namespaces. +*/ +if (current_user_ns () != &init_user_ns) { +if (old_ma->fsx_projid != ma->fsx_projid) +return -EINVAL ; +if ((old_ma->fsx_xflags ^ ma->fsx_xflags) & +FS_XFLAG_PROJINHERIT ) +return -EINVAL ; + } + +/* Check extent size hints. */ +if ((ma->fsx_xflags &FS_XFLAG_EXTSIZE ) && !S_ISREG (inode->i_mode)) +return -EINVAL ; + +if ((ma->fsx_xflags &FS_XFLAG_EXTSZINHERIT ) && + !S_ISDIR (inode->i_mode)) +return -EINVAL ; + +if ((ma->fsx_xflags &FS_XFLAG_COWEXTSIZE ) && + !S_ISREG (inode->i_mode) && !S_ISDIR (inode->i_mode)) +return -EINVAL ; + +/* +* It is only valid to set the DAX flag on regular files and +* directories on filesystems. +*/ +if ((ma->fsx_xflags &FS_XFLAG_DAX ) && + !(S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode))) +return -EINVAL ; + +/* Extent size hints of zero turn off the flags. */ +if (ma->fsx_extsize ==0 ) + ma->fsx_xflags &= ~(FS_XFLAG_EXTSIZE |FS_XFLAG_EXTSZINHERIT ); +if (ma->fsx_cowextsize ==0 ) + ma->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE ; + +return 0 ; +} + +/** +* vfs_miscattr_set - change miscellaneous inode attributes +* @dentry: the object to change +* @ma: miscattr pointer +* +* After verifying permissions, call i_op->miscattr_set() callback, if +* exists. +* +* Verifying attributes involves retrieving current attributes with +* i_op->miscattr_get(), this also allows initilaizing attributes that have +* not been set by the caller to current values. Inode lock is held +* thoughout to prevent racing with another instance. +* +* Returns 0 on success, or a negative error on failure. +*/ +int vfs_miscattr_set (struct user_namespace *mnt_userns,struct dentry *dentry, +struct miscattr *ma) +{ +struct inode *inode =d_inode (dentry); +struct miscattr old_ma = {}; +int err; + +if (d_is_special (dentry)) +return -ENOTTY ; + +if (!inode->i_op->miscattr_set) +return -ENOIOCTLCMD ; + +if (!inode_owner_or_capable (mnt_userns, inode)) +return -EPERM ; + +inode_lock (inode); + err =vfs_miscattr_get (dentry, &old_ma); +if (!err) { +/* initialize missing bits from old_ma */ +if (ma->flags_valid) { + ma->fsx_xflags |= old_ma.fsx_xflags & ~FS_XFLAG_COMMON ; + ma->fsx_extsize = old_ma.fsx_extsize; + ma->fsx_nextents = old_ma.fsx_nextents; + ma->fsx_projid = old_ma.fsx_projid; + ma->fsx_cowextsize = old_ma.fsx_cowextsize; + }else { + ma->flags |= old_ma.flags & ~FS_COMMON_FL ; + } + err =miscattr_set_prepare (inode, &old_ma, ma); +if (!err) + err = inode->i_op->miscattr_set (mnt_userns, dentry, ma); + } +inode_unlock (inode); + +return err; +} +EXPORT_SYMBOL (vfs_miscattr_set); + +static int ioctl_getflags (struct file *file,void __user *argp) +{ +struct miscattr ma = { .flags_valid = true };/* hint only */ +unsigned int flags; +int err; + + err =vfs_miscattr_get (file_dentry (file), &ma); +if (!err) { + flags = ma.flags; +if (copy_to_user (argp, &flags,sizeof (flags))) + err = -EFAULT ; + } +return err; +} + +static int ioctl_setflags (struct file *file,void __user *argp) +{ +struct miscattr ma; +unsigned int flags; +int err; + +if (copy_from_user (&flags, argp,sizeof (flags))) +return -EFAULT ; + + err =mnt_want_write_file (file); +if (!err) { +miscattr_fill_flags (&ma, flags); + err =vfs_miscattr_set (file_mnt_user_ns (file),file_dentry (file), &ma); +mnt_drop_write_file (file); + } +return err; +} + +static int ioctl_fsgetxattr (struct file *file,void __user *argp) +{ +struct miscattr ma = { .xattr_valid = true };/* hint only */ +int err; + + err =vfs_miscattr_get (file_dentry (file), &ma); +if (!err) + err =fsxattr_copy_to_user (&ma, argp); + +return err; +} + +static int ioctl_fssetxattr (struct file *file,void __user *argp) +{ +struct miscattr ma; +int err; + + err =fsxattr_copy_from_user (&ma, argp); +if (!err) { + err =mnt_want_write_file (file); +if (!err) { + err =vfs_miscattr_set (file_mnt_user_ns (file),file_dentry (file), &ma); +mnt_drop_write_file (file); + } + } +return err; +} +/* * do_vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d. * It's just a simple helper for sys_ioctl and compat_sys_ioctl. @@ -727,6 +1035,18 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,return put_user (i_size_read (inode) - filp->f_pos, (int __user *)argp); +case FS_IOC_GETFLAGS : +return ioctl_getflags (filp, argp); + +case FS_IOC_SETFLAGS : +return ioctl_setflags (filp, argp); + +case FS_IOC_FSGETXATTR : +return ioctl_fsgetxattr (filp, argp); + +case FS_IOC_FSSETXATTR : +return ioctl_fssetxattr (filp, argp); +default :if (S_ISREG (inode->i_mode))return file_ioctl (filp, cmd, argp);@@ -827,6 +1147,15 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,break ;#endif +/* +* These access 32-bit values anyway so no further handling is +* necessary. +*/ +case FS_IOC32_GETFLAGS : +case FS_IOC32_SETFLAGS : + cmd = (cmd ==FS_IOC32_GETFLAGS ) ? +FS_IOC_GETFLAGS :FS_IOC_SETFLAGS ; + fallthrough;/* * everything else in do_vfs_ioctl() takes either a compatible * pointer argument or no argument -- call it with a modified include/linux/fs.h +4
-0@@ -70,6 +70,7 @@ struct fsverity_info;struct fsverity_operations ;struct fs_context ;struct fs_parameter_spec ; +struct miscattr ;extern void __init inode_init (void );extern void __init inode_init_early (void );@@ -1963,6 +1964,9 @@ struct inode_operations { struct dentry *, umode_t);int (*set_acl)(struct user_namespace *,struct inode *,struct posix_acl *,int ); +int (*miscattr_set)(struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma); +int (*miscattr_get)(struct dentry *dentry,struct miscattr *ma); }____cacheline_aligned ; static inline ssize_t call_read_iter(struct file *file, struct kiocb *kio,include/linux/miscattr.h new file +10
-0@@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_MISCATTR_H +#define _LINUX_MISCATTR_H + +/* Flags shared betwen flags/xflags */ +#define FS_COMMON_FL \ + (FS_SYNC_FL | FS_IMMUTABLE_FL | FS_APPEND_FL | \ + FS_NODUMP_FL | FS_NOATIME_FL | FS_DAX_FL | \ + FS_PROJINHERIT_FL)
include/linux/miscattr.h line 20
Quoted 10 lines
include/linux/miscattr.h new file +10
-0+ +#define FS_XFLAG_COMMON \ + (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | \ + FS_XFLAG_NODUMP | FS_XFLAG_NOATIME | FS_XFLAG_DAX | \ + FS_XFLAG_PROJINHERIT) + +struct miscattr { +u32 flags;/* flags (FS_IOC_GETFLAGS/FS_IOC_SETFLAGS) */ +/* struct fsxattr: */ +u32 fsx_xflags;/* xflags field value (get/set) */
Hrmm... could we have /some/ note here that fsx_xflags comes from XFS and "flags" comes from ext*?
include/linux/miscattr.h line 27
Quoted 7 lines
include/linux/miscattr.h new file +7
-0+u32 fsx_extsize;/* extsize field value (get/set)*/ +u32 fsx_nextents;/* nextents field value (get) */ +u32 fsx_projid;/* project identifier (get/set) */ +u32 fsx_cowextsize;/* CoW extsize field value (get/set)*/ +/* selectors: */ + bool flags_valid:1; + bool xattr_valid:1;
What does this have to do with extended attributes?
OH, it has nothing to do with xattrs; this flag means that the fsx_* fields of miscattr have any significance. Can this be named fsx_valid?
So what should XFS do here? Set the fsx_* fields, clear flags_valid, and set fsx_valid?
Oh, I guess there's an XFS conversion patch, so I'll wander off there now.
--D
Quoted 29 lines
include/linux/miscattr.h new file +26
-0+}; + +int fsxattr_copy_to_user (const struct miscattr *ma,struct fsxattr __user *ufa); + +void miscattr_fill_xflags (struct miscattr *ma,u32 xflags); +void miscattr_fill_flags (struct miscattr *ma,u32 flags); + +/** +* miscattr_has_xattr - check for extentended flags/attributes +* @ma: miscattr pointer +* +* Returns true if any attributes are present that are not represented in +* ->flags. +*/ +static inline bool miscattr_has_xattr (const struct miscattr *ma) +{ +return ma->xattr_valid && + ((ma->fsx_xflags & ~FS_XFLAG_COMMON ) || ma->fsx_extsize !=0 || + ma->fsx_projid !=0 || ma->fsx_cowextsize !=0 ); +} + +int vfs_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int vfs_miscattr_set (struct user_namespace *mnt_userns,struct dentry *dentry, +struct miscattr *ma); + +#endif /* _LINUX_MISCATTR_H */ Signature · 1 line
2.30.2
Amir Goldstein
maintainerRe: [PATCH v2 01/18] vfs: add miscattr ops
Quoted 9 lines
Quoted 1 line
+``miscattr_get``
I wish this wasn't named "misc" because miscellaneous is vague.
fileattr_get, perhaps?(FWIW I'm not /that/ passionate about starting a naming bikeshed, feel free to ignore.)
Eventual bikeshedding is hard to avoid in this case...
I don't feel strongly against "misc", but I do think the flags and ioctl are already
known as "fsx" so it would be more friendly to go with that.
If you don't like "fsxflags" because it's not only flags and you think "fsxattr" is too
close to "xattr" (FWIW I don't think it is going to be a source of confusion), we
can simply go with get_fsx(), similar to get_acl(). It doesn't matter what name we
use as long as everyone is clear on what it is.
"struct fsx" is not any more or any less clear than "struct statx" and while "fsx"
it is a pretty arbitrary name, it is not much less arbitrary than "miscattr".
Thanks,
Amir.
Re: [PATCH v2 01/18] vfs: add miscattr ops
In reply to Darrick J. WongQuoted 12 lines · Darrick J. Wong
Quoted 11 lines · Miklos Szeredi
Documentation/filesystems/vfs.rst +3
-0@@ -441,6 +441,9 @@ As of kernel 2.6.22, the following members are defined: unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct user_namespace *, struct inode *, struct dentry *, umode_t); int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); };
Quoted 8 lines
Documentation/filesystems/vfs.rst otherwise noted. · line 594
Quoted 6 lines
Documentation/filesystems/vfs.rst +1
-0Again, all methods are called without any locks being held, unless@@ -588,6 +591,18 @@ otherwise noted. atomically creating, opening and unlinking a file in given directory. +``miscattr_get``I wish this wasn't named "misc" because miscellaneous is vague.
It also adds yet another way to name all the attributes (the "N + 1st standard" problem). So I'd rather reuse a term that's already known and understood by users. And this is 'file attributes', eg. as noted in chattr manual page "change file attributes on a Linux file system". For clarity avoid any 'x' in the name so we easily distinguish that from the extended attributes aka xattrs.
We can perhaps live with miscattrs in code as anybody who has ever touched the flags/attrs interfaces knows what it is referring to.
Quoted 1 line
fileattr_get, perhaps?
That sounds about right to me.
Re: [PATCH v2 01/18] vfs: add miscattr ops
In reply to Darrick J. WongQuoted 530 lines · Darrick J. Wong
Quoted 70 lines · Miklos Szeredi
There's a substantial amount of boilerplate in filesystems handling FS_IOC_[GS]ETFLAGS/ FS_IOC_FS[GS]ETXATTR ioctls.
Also due to userspace buffers being involved in the ioctl API this is difficult to stack, as shown by overlayfs issues related to these ioctls.
Introduce a new internal API named "miscattr" (fsxattr can be confused with xattr, xflags is inappropriate, since this is more than just flags).
There's significant overlap between flags and xflags and this API handles the conversions automatically, so filesystems may choose which one to use.
In ->miscattr_get() a hint is provided to the filesystem whether flags or xattr are being requested by userspace, but in this series this hint is ignored by all filesystems, since generating all the attributes is cheap.
If a filesystem doesn't implemement the miscattr API, just fall back to
f_op->ioctl(). When all filesystems are converted, the fallback can be removed.32bit compat ioctls are now handled by the generic code as well.
Signed-off-by Miklos Szeredi <[email protected]>--- Documentation/filesystems/locking.rst | 5 + Documentation/filesystems/vfs.rst | 15 ++ fs/ioctl.c | 329 ++++++++++++++++++++++++++ include/linux/fs.h | 4 + include/linux/miscattr.h | 53 +++++ 5 files changed, 406 insertions(+) create mode 100644 include/linux/miscattr.hDocumentation/filesystems/locking.rst +5
-0@@ -80,6 +80,9 @@ prototypes:: struct file *, unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct inode *, struct dentry *, umode_t); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); locking rules: all may block@@ -107,6 +110,8 @@ fiemap: no update_time: no atomic_open: shared (exclusive if O_CREAT is set in open flags) tmpfile: no +miscattr_get: no or exclusive +miscattr_set: exclusive ============ =============================================Documentation/filesystems/vfs.rst +3
-0@@ -441,6 +441,9 @@ As of kernel 2.6.22, the following members are defined: unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct user_namespace *, struct inode *, struct dentry *, umode_t); int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); }; Again, all methods are called without any locks being held, unlessDocumentation/filesystems/vfs.rst otherwise noted. · line 594
Quoted 4 lines
Documentation/filesystems/vfs.rst +1
-0@@ -588,6 +591,18 @@ otherwise noted. atomically creating, opening and unlinking a file in given directory. +``miscattr_get``I wish this wasn't named "misc" because miscellaneous is vague.
fileattr_get, perhaps?(FWIW I'm not /that/ passionate about starting a naming bikeshed, feel free to ignore.)
Documentation/filesystems/vfs.rst otherwise noted. · line 596
Quoted 2 lines
Documentation/filesystems/vfs.rst +2
-0+ called on ioctl(FS_IOC_GETFLAGS) and ioctl(FS_IOC_FSGETXATTR) to + retrieve miscellaneous filesystem flags and attributes. Also"...miscellaneous *file* flags and attributes."
Documentation/filesystems/vfs.rst otherwise noted. · line 603
Quoted 7 lines
Documentation/filesystems/vfs.rst +7
-0+ called before the relevant SET operation to check what is being + changed (in this case with i_rwsem locked exclusive). If unset, + then fall back to f_op->ioctl(). + +``miscattr_set`` + called on ioctl(FS_IOC_SETFLAGS) and ioctl(FS_IOC_FSSETXATTR) to + change miscellaneous filesystem flags and attributes. Callers holdSame here.
Quoted 28 lines
Documentation/filesystems/vfs.rst +2
-0+ i_rwsem exclusive. If unset, then fall back to f_op->ioctl(). + The Address Space Object ========================fs/ioctl.c +8
-0@@ -19,6 +19,9 @@#include <linux/falloc.h> #include <linux/sched/signal.h> #include <linux/fiemap.h> +#include <linux/mount.h> +#include <linux/fscrypt.h> +#include <linux/miscattr.h> #include "internal.h" @@ -657,6 +660,311 @@ static int ioctl_file_dedupe_range(struct file *file,return ret; } +/** +* miscattr_fill_xflags - initialize miscattr with xflags +* @ma: miscattr pointer +* @xflags: FS_XFLAG_* flags +* fs/ioctl.c static int ioctl_file_dedupe_range(struct file *file, · line 677
Quoted 10 lines
fs/ioctl.c +10
-0+* Set ->fsx_xflags, ->xattr_valid and ->flags (translated xflags). All +* other fields are zeroed. +*/ +void miscattr_fill_xflags (struct miscattr *ma,u32 xflags) +{ +memset (ma,0 ,sizeof (*ma)); + ma->xattr_valid = true; + ma->fsx_xflags = xflags; +if (ma->fsx_xflags &FS_XFLAG_IMMUTABLE ) + ma->flags |=FS_IMMUTABLE_FL ;I wonder if maintaining redundant sets of flags in the same structure is going to bite us some day.
Quoted 366 lines
fs/ioctl.c +311
-0+if (ma->fsx_xflags &FS_XFLAG_APPEND ) + ma->flags |=FS_APPEND_FL ; +if (ma->fsx_xflags &FS_XFLAG_SYNC ) + ma->flags |=FS_SYNC_FL ; +if (ma->fsx_xflags &FS_XFLAG_NOATIME ) + ma->flags |=FS_NOATIME_FL ; +if (ma->fsx_xflags &FS_XFLAG_NODUMP ) + ma->flags |=FS_NODUMP_FL ; +if (ma->fsx_xflags &FS_XFLAG_DAX ) + ma->flags |=FS_DAX_FL ; +if (ma->fsx_xflags &FS_XFLAG_PROJINHERIT ) + ma->flags |=FS_PROJINHERIT_FL ; +} +EXPORT_SYMBOL (miscattr_fill_xflags); + +/** +* miscattr_fill_flags - initialize miscattr with flags +* @ma: miscattr pointer +* @flags: FS_*_FL flags +* +* Set ->flags, ->flags_valid and ->fsx_xflags (translated flags). +* All other fields are zeroed. +*/ +void miscattr_fill_flags (struct miscattr *ma,u32 flags) +{ +memset (ma,0 ,sizeof (*ma)); + ma->flags_valid = true; + ma->flags = flags; +if (ma->flags &FS_SYNC_FL ) + ma->fsx_xflags |=FS_XFLAG_SYNC ; +if (ma->flags &FS_IMMUTABLE_FL ) + ma->fsx_xflags |=FS_XFLAG_IMMUTABLE ; +if (ma->flags &FS_APPEND_FL ) + ma->fsx_xflags |=FS_XFLAG_APPEND ; +if (ma->flags &FS_NODUMP_FL ) + ma->fsx_xflags |=FS_XFLAG_NODUMP ; +if (ma->flags &FS_NOATIME_FL ) + ma->fsx_xflags |=FS_XFLAG_NOATIME ; +if (ma->flags &FS_DAX_FL ) + ma->fsx_xflags |=FS_XFLAG_DAX ; +if (ma->flags &FS_PROJINHERIT_FL ) + ma->fsx_xflags |=FS_XFLAG_PROJINHERIT ; +} +EXPORT_SYMBOL (miscattr_fill_flags); + +/** +* vfs_miscattr_get - retrieve miscellaneous inode attributes +* @dentry: the object to retrieve from +* @ma: miscattr pointer +* +* Call i_op->miscattr_get() callback, if exists. +* +* Returns 0 on success, or a negative error on failure. +*/ +int vfs_miscattr_get (struct dentry *dentry,struct miscattr *ma) +{ +struct inode *inode =d_inode (dentry); + +if (d_is_special (dentry)) +return -ENOTTY ; + +if (!inode->i_op->miscattr_get) +return -ENOIOCTLCMD ; + +return inode->i_op->miscattr_get (dentry, ma); +} +EXPORT_SYMBOL (vfs_miscattr_get); + +/** +* fsxattr_copy_to_user - copy fsxattr to userspace. +* @ma: miscattr pointer +* @ufa: fsxattr user pointer +* +* Returns 0 on success, or -EFAULT on failure. +*/ +int fsxattr_copy_to_user (const struct miscattr *ma,struct fsxattr __user *ufa) +{ +struct fsxattr fa = { + .fsx_xflags = ma->fsx_xflags, + .fsx_extsize = ma->fsx_extsize, + .fsx_nextents = ma->fsx_nextents, + .fsx_projid = ma->fsx_projid, + .fsx_cowextsize = ma->fsx_cowextsize, + }; + +if (copy_to_user (ufa, &fa,sizeof (fa))) +return -EFAULT ; + +return 0 ; +} +EXPORT_SYMBOL (fsxattr_copy_to_user); + +static int fsxattr_copy_from_user (struct miscattr *ma, +struct fsxattr __user *ufa) +{ +struct fsxattr fa; + +if (copy_from_user (&fa, ufa,sizeof (fa))) +return -EFAULT ; + +miscattr_fill_xflags (ma, fa.fsx_xflags); + ma->fsx_extsize = fa.fsx_extsize; + ma->fsx_nextents = fa.fsx_nextents; + ma->fsx_projid = fa.fsx_projid; + ma->fsx_cowextsize = fa.fsx_cowextsize; + +return 0 ; +} + +/* +* Generic function to check FS_IOC_FSSETXATTR/FS_IOC_SETFLAGS values and reject +* any invalid configurations. +* +* Note: must be called with inode lock held. +*/ +static int miscattr_set_prepare (struct inode *inode, +const struct miscattr *old_ma, +struct miscattr *ma) +{ +int err; + +/* +* The IMMUTABLE and APPEND_ONLY flags can only be changed by +* the relevant capability. +*/ +if ((ma->flags ^ old_ma->flags) & (FS_APPEND_FL |FS_IMMUTABLE_FL ) && + !capable (CAP_LINUX_IMMUTABLE )) +return -EPERM ; + + err =fscrypt_prepare_setflags (inode, old_ma->flags, ma->flags); +if (err) +return err; + +/* +* Project Quota ID state is only allowed to change from within the init +* namespace. Enforce that restriction only if we are trying to change +* the quota ID state. Everything else is allowed in user namespaces. +*/ +if (current_user_ns () != &init_user_ns) { +if (old_ma->fsx_projid != ma->fsx_projid) +return -EINVAL ; +if ((old_ma->fsx_xflags ^ ma->fsx_xflags) & +FS_XFLAG_PROJINHERIT ) +return -EINVAL ; + } + +/* Check extent size hints. */ +if ((ma->fsx_xflags &FS_XFLAG_EXTSIZE ) && !S_ISREG (inode->i_mode)) +return -EINVAL ; + +if ((ma->fsx_xflags &FS_XFLAG_EXTSZINHERIT ) && + !S_ISDIR (inode->i_mode)) +return -EINVAL ; + +if ((ma->fsx_xflags &FS_XFLAG_COWEXTSIZE ) && + !S_ISREG (inode->i_mode) && !S_ISDIR (inode->i_mode)) +return -EINVAL ; + +/* +* It is only valid to set the DAX flag on regular files and +* directories on filesystems. +*/ +if ((ma->fsx_xflags &FS_XFLAG_DAX ) && + !(S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode))) +return -EINVAL ; + +/* Extent size hints of zero turn off the flags. */ +if (ma->fsx_extsize ==0 ) + ma->fsx_xflags &= ~(FS_XFLAG_EXTSIZE |FS_XFLAG_EXTSZINHERIT ); +if (ma->fsx_cowextsize ==0 ) + ma->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE ; + +return 0 ; +} + +/** +* vfs_miscattr_set - change miscellaneous inode attributes +* @dentry: the object to change +* @ma: miscattr pointer +* +* After verifying permissions, call i_op->miscattr_set() callback, if +* exists. +* +* Verifying attributes involves retrieving current attributes with +* i_op->miscattr_get(), this also allows initilaizing attributes that have +* not been set by the caller to current values. Inode lock is held +* thoughout to prevent racing with another instance. +* +* Returns 0 on success, or a negative error on failure. +*/ +int vfs_miscattr_set (struct user_namespace *mnt_userns,struct dentry *dentry, +struct miscattr *ma) +{ +struct inode *inode =d_inode (dentry); +struct miscattr old_ma = {}; +int err; + +if (d_is_special (dentry)) +return -ENOTTY ; + +if (!inode->i_op->miscattr_set) +return -ENOIOCTLCMD ; + +if (!inode_owner_or_capable (mnt_userns, inode)) +return -EPERM ; + +inode_lock (inode); + err =vfs_miscattr_get (dentry, &old_ma); +if (!err) { +/* initialize missing bits from old_ma */ +if (ma->flags_valid) { + ma->fsx_xflags |= old_ma.fsx_xflags & ~FS_XFLAG_COMMON ; + ma->fsx_extsize = old_ma.fsx_extsize; + ma->fsx_nextents = old_ma.fsx_nextents; + ma->fsx_projid = old_ma.fsx_projid; + ma->fsx_cowextsize = old_ma.fsx_cowextsize; + }else { + ma->flags |= old_ma.flags & ~FS_COMMON_FL ; + } + err =miscattr_set_prepare (inode, &old_ma, ma); +if (!err) + err = inode->i_op->miscattr_set (mnt_userns, dentry, ma); + } +inode_unlock (inode); + +return err; +} +EXPORT_SYMBOL (vfs_miscattr_set); + +static int ioctl_getflags (struct file *file,void __user *argp) +{ +struct miscattr ma = { .flags_valid = true };/* hint only */ +unsigned int flags; +int err; + + err =vfs_miscattr_get (file_dentry (file), &ma); +if (!err) { + flags = ma.flags; +if (copy_to_user (argp, &flags,sizeof (flags))) + err = -EFAULT ; + } +return err; +} + +static int ioctl_setflags (struct file *file,void __user *argp) +{ +struct miscattr ma; +unsigned int flags; +int err; + +if (copy_from_user (&flags, argp,sizeof (flags))) +return -EFAULT ; + + err =mnt_want_write_file (file); +if (!err) { +miscattr_fill_flags (&ma, flags); + err =vfs_miscattr_set (file_mnt_user_ns (file),file_dentry (file), &ma); +mnt_drop_write_file (file); + } +return err; +} + +static int ioctl_fsgetxattr (struct file *file,void __user *argp) +{ +struct miscattr ma = { .xattr_valid = true };/* hint only */ +int err; + + err =vfs_miscattr_get (file_dentry (file), &ma); +if (!err) + err =fsxattr_copy_to_user (&ma, argp); + +return err; +} + +static int ioctl_fssetxattr (struct file *file,void __user *argp) +{ +struct miscattr ma; +int err; + + err =fsxattr_copy_from_user (&ma, argp); +if (!err) { + err =mnt_want_write_file (file); +if (!err) { + err =vfs_miscattr_set (file_mnt_user_ns (file),file_dentry (file), &ma); +mnt_drop_write_file (file); + } + } +return err; +} +/* * do_vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d. * It's just a simple helper for sys_ioctl and compat_sys_ioctl. @@ -727,6 +1035,18 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,return put_user (i_size_read (inode) - filp->f_pos, (int __user *)argp); +case FS_IOC_GETFLAGS : +return ioctl_getflags (filp, argp); + +case FS_IOC_SETFLAGS : +return ioctl_setflags (filp, argp); + +case FS_IOC_FSGETXATTR : +return ioctl_fsgetxattr (filp, argp); + +case FS_IOC_FSSETXATTR : +return ioctl_fssetxattr (filp, argp); +default :if (S_ISREG (inode->i_mode))return file_ioctl (filp, cmd, argp);@@ -827,6 +1147,15 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,break ;#endif +/* +* These access 32-bit values anyway so no further handling is +* necessary. +*/ +case FS_IOC32_GETFLAGS : +case FS_IOC32_SETFLAGS : + cmd = (cmd ==FS_IOC32_GETFLAGS ) ? +FS_IOC_GETFLAGS :FS_IOC_SETFLAGS ; + fallthrough;/* * everything else in do_vfs_ioctl() takes either a compatible * pointer argument or no argument -- call it with a modified include/linux/fs.h +4
-0@@ -70,6 +70,7 @@ struct fsverity_info;struct fsverity_operations ;struct fs_context ;struct fs_parameter_spec ; +struct miscattr ;extern void __init inode_init (void );extern void __init inode_init_early (void );@@ -1963,6 +1964,9 @@ struct inode_operations { struct dentry *, umode_t);int (*set_acl)(struct user_namespace *,struct inode *,struct posix_acl *,int ); +int (*miscattr_set)(struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma); +int (*miscattr_get)(struct dentry *dentry,struct miscattr *ma); }____cacheline_aligned ; static inline ssize_t call_read_iter(struct file *file, struct kiocb *kio,include/linux/miscattr.h new file +10
-0@@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_MISCATTR_H +#define _LINUX_MISCATTR_H + +/* Flags shared betwen flags/xflags */ +#define FS_COMMON_FL \ + (FS_SYNC_FL | FS_IMMUTABLE_FL | FS_APPEND_FL | \ + FS_NODUMP_FL | FS_NOATIME_FL | FS_DAX_FL | \ + FS_PROJINHERIT_FL)include/linux/miscattr.h line 20
Quoted 10 lines
include/linux/miscattr.h new file +10
-0+ +#define FS_XFLAG_COMMON \ + (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | \ + FS_XFLAG_NODUMP | FS_XFLAG_NOATIME | FS_XFLAG_DAX | \ + FS_XFLAG_PROJINHERIT) + +struct miscattr { +u32 flags;/* flags (FS_IOC_GETFLAGS/FS_IOC_SETFLAGS) */ +/* struct fsxattr: */ +u32 fsx_xflags;/* xflags field value (get/set) */ Hrmm... could we have /some/ note here that
fsx_xflagscomes from XFS and "flags" comes from ext*?include/linux/miscattr.h line 27
Quoted 7 lines
include/linux/miscattr.h new file +7
-0+u32 fsx_extsize;/* extsize field value (get/set)*/ +u32 fsx_nextents;/* nextents field value (get) */ +u32 fsx_projid;/* project identifier (get/set) */ +u32 fsx_cowextsize;/* CoW extsize field value (get/set)*/ +/* selectors: */ + bool flags_valid:1; + bool xattr_valid:1;What does this have to do with extended attributes?
Quoted 2 lines
OH, it has nothing to do with xattrs; this flag means that the fsx_* fields of miscattr have any significance. Can this be named
fsx_valid?
Yeah, that confused me too. If this is really related to fsx then naming it fsx_valid would be potentially nicer.
Christian
Al Viro
maintainerRe: [PATCH v2 01/18] vfs: add miscattr ops
In reply to Miklos SzerediOn Mon, Mar 22, 2021 at 03:48:59PM +0100, Miklos Szeredi wrote:
minor nit: copy_fsxattr_{to,from}_user() might be better.
fs/ioctl.c static int ioctl_file_dedupe_range(struct file *file, · line 761
Quoted 9 lines
fs/ioctl.c +9
-0+int fsxattr_copy_to_user (const struct miscattr *ma,struct fsxattr __user *ufa) +{ +struct fsxattr fa = { + .fsx_xflags = ma->fsx_xflags, + .fsx_extsize = ma->fsx_extsize, + .fsx_nextents = ma->fsx_nextents, + .fsx_projid = ma->fsx_projid, + .fsx_cowextsize = ma->fsx_cowextsize, + };
That wants a comment along the lines of "guaranteed to be gap-free", since otherwise you'd need memset() to avoid an infoleak.
fs/ioctl.c static int ioctl_file_dedupe_range(struct file *file, · line 913
Quoted 7 lines
fs/ioctl.c +7
-0+static int ioctl_getflags (struct file *file,void __user *argp) +{ +struct miscattr ma = { .flags_valid = true };/* hint only */ +unsigned int flags; +int err; + + err =vfs_miscattr_get (file_dentry (file), &ma);
Umm... Just to clarify - do we plan to have that ever called via ovl_real_ioctl()? IOW, is file_dentry() anything other than a way to spell ->f_path.dentry here?
include/linux/miscattr.h line 28
Quoted 12 lines
include/linux/miscattr.h new file +12
-0+struct miscattr { +u32 flags;/* flags (FS_IOC_GETFLAGS/FS_IOC_SETFLAGS) */ +/* struct fsxattr: */ +u32 fsx_xflags;/* xflags field value (get/set) */ +u32 fsx_extsize;/* extsize field value (get/set)*/ +u32 fsx_nextents;/* nextents field value (get) */ +u32 fsx_projid;/* project identifier (get/set) */ +u32 fsx_cowextsize;/* CoW extsize field value (get/set)*/ +/* selectors: */ +bool flags_valid:1 ; +bool xattr_valid:1 ; +};
OK as long as it stays kernel-only, but if we ever expose that to userland, we'd better remember to turn the last two into an u32 with explicit bitmasks.
Miklos Szeredi
maintainerRe: [PATCH v2 01/18] vfs: add miscattr ops
Quoted 5 lines · Al Viro
On Mon, Mar 22, 2021 at 03:48:59PM +0100, Miklos Szeredi wrote:
minor nit: copy_fsxattr_{to,from}_user() might be better.
Quoted 12 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+int fsxattr_copy_to_user(const struct miscattr *ma, struct fsxattr __user *ufa) +{ + struct fsxattr fa = { + .fsx_xflags = ma->fsx_xflags, + .fsx_extsize = ma->fsx_extsize, + .fsx_nextents = ma->fsx_nextents, + .fsx_projid = ma->fsx_projid, + .fsx_cowextsize = ma->fsx_cowextsize, + };That wants a comment along the lines of "guaranteed to be gap-free", since otherwise you'd need
memset()to avoid an infoleak.
Isn't structure initialization supposed to zero everything not explicitly initialized?
Quoted 12 lines
Review
Quoted 8 lines
(quoted diff) +7
-0+static int ioctl_getflags(struct file *file, void __user *argp) +{ + struct miscattr ma = { .flags_valid = true }; /* hint only */ + unsigned int flags; + int err; + + err = vfs_miscattr_get(file_dentry(file), &ma);Umm... Just to clarify - do we plan to have that ever called via
ovl_real_ioctl()? IOW, isfile_dentry()anything other than a way to spell ->f_path.dentry here?
Indeed, file_dentry() only makes sense when called from a layer inside overlayfs.
The one in io_uring() seems wrong also, as a beast needing file_dentry() should never get out of overlayfs and into io_uring:
fs/io_uring.c +0 -0
@@ -9297,7 +9297,7 @@ static void __io_uring_show_fdinfo(struct
io_ring_ctx *ctx, struct seq_file *m)
struct file *f = *io_fixed_file_slot(ctx->file_data, i);
if (f)
- seq_printf(m, "%5u: %s\n", i, file_dentry(f)->d_iname);
+ seq_printf(m, "%5u: %pD\n", i, f);
else
seq_printf(m, "%5u: <none>\n", i);
}Thanks,
Miklos
Al Viro
maintainerRe: [PATCH v2 01/18] vfs: add miscattr ops
Quoted 19 lines · Miklos Szeredi
Quoted 5 lines · Al Viro
On Mon, Mar 22, 2021 at 03:48:59PM +0100, Miklos Szeredi wrote:
minor nit: copy_fsxattr_{to,from}_user() might be better.
Quoted 12 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+int fsxattr_copy_to_user(const struct miscattr *ma, struct fsxattr __user *ufa) +{ + struct fsxattr fa = { + .fsx_xflags = ma->fsx_xflags, + .fsx_extsize = ma->fsx_extsize, + .fsx_nextents = ma->fsx_nextents, + .fsx_projid = ma->fsx_projid, + .fsx_cowextsize = ma->fsx_cowextsize, + };That wants a comment along the lines of "guaranteed to be gap-free", since otherwise you'd need
memset()to avoid an infoleak.
Quoted 2 lines
Isn't structure initialization supposed to zero everything not explicitly initialized?
All fields, but not the padding...
Quoted 2 lines
The one in
io_uring()seems wrong also, as a beast needingfile_dentry()should never get out of overlayfs and intoio_uring:
That one would be wrong in overlayfs as well - we'd better had the same names in all layers...
Quoted 16 lines
fs/io_uring.c +1
-1@@ -9297,7 +9297,7 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) struct file *f = *io_fixed_file_slot(ctx->file_data, i);if (f) -seq_printf (m,"%5u: %s\n" , i,file_dentry (f)->d_iname); +seq_printf (m,"%5u: %pD\n" , i, f);else seq_printf (m,"%5u: <none>\n" , i);}Thanks,
Miklos
Miklos Szeredi
maintainerRe: [PATCH v2 01/18] vfs: add miscattr ops
Quoted 7 lines · Al Viro
Quoted 2 lines · Miklos Szeredi
Isn't structure initialization supposed to zero everything not explicitly initialized?
All fields, but not the padding...
Ah... while the structure is unlikely to change, I'll switch to memset to be safe.
Quoted 6 lines
Quoted 3 lines
The one in
io_uring()seems wrong also, as a beast needingfile_dentry()should never get out of overlayfs and intoio_uring:That one would be wrong in overlayfs as well - we'd better had the same names in all layers...
Right.
Thanks,
Miklos
Re: [PATCH v2 01/18] vfs: add miscattr ops
In reply to Miklos SzerediQuoted 16 lines · Miklos Szeredi
There's a substantial amount of boilerplate in filesystems handling FS_IOC_[GS]ETFLAGS/ FS_IOC_FS[GS]ETXATTR ioctls.
Also due to userspace buffers being involved in the ioctl API this is difficult to stack, as shown by overlayfs issues related to these ioctls.
Introduce a new internal API named "miscattr" (fsxattr can be confused with xattr, xflags is inappropriate, since this is more than just flags).
There's significant overlap between flags and xflags and this API handles the conversions automatically, so filesystems may choose which one to use.
In ->miscattr_get() a hint is provided to the filesystem whether flags or xattr are being requested by userspace, but in this series this hint is ignored by all filesystems, since generating all the attributes is cheap.
Quoted 8 lines
If a filesystem doesn't implemement the miscattr API, just fall back to
f_op->ioctl(). When all filesystems are converted, the fallback can be removed.32bit compat ioctls are now handled by the generic code as well.
Signed-off-by Miklos Szeredi <[email protected]>---
Fwiw, I think this is a good cleanup. Changing something like the miscattr_set() method to take a mnt_userns would've been less churn then having to audit all ioctls individually.
(Only one small comment below.)
Quoted 264 lines
Documentation/filesystems/locking.rst | 5 + Documentation/filesystems/vfs.rst | 15 ++ fs/ioctl.c | 329 ++++++++++++++++++++++++++ include/linux/fs.h | 4 + include/linux/miscattr.h | 53 +++++ 5 files changed, 406 insertions(+) create mode 100644 include/linux/miscattr.hDocumentation/filesystems/locking.rst +5
-0@@ -80,6 +80,9 @@ prototypes:: struct file *, unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct inode *, struct dentry *, umode_t); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); locking rules: all may block@@ -107,6 +110,8 @@ fiemap: no update_time: no atomic_open: shared (exclusive if O_CREAT is set in open flags) tmpfile: no +miscattr_get: no or exclusive +miscattr_set: exclusive ============ =============================================Documentation/filesystems/vfs.rst +15
-0@@ -441,6 +441,9 @@ As of kernel 2.6.22, the following members are defined: unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct user_namespace *, struct inode *, struct dentry *, umode_t); int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int); + int (*miscattr_set)(struct user_namespace *mnt_userns, + struct dentry *dentry, struct miscattr *ma); + int (*miscattr_get)(struct dentry *dentry, struct miscattr *ma); }; Again, all methods are called without any locks being held, unless@@ -588,6 +591,18 @@ otherwise noted. atomically creating, opening and unlinking a file in given directory. +``miscattr_get`` + called on ioctl(FS_IOC_GETFLAGS) and ioctl(FS_IOC_FSGETXATTR) to + retrieve miscellaneous filesystem flags and attributes. Also + called before the relevant SET operation to check what is being + changed (in this case with i_rwsem locked exclusive). If unset, + then fall back to f_op->ioctl(). + +``miscattr_set`` + called on ioctl(FS_IOC_SETFLAGS) and ioctl(FS_IOC_FSSETXATTR) to + change miscellaneous filesystem flags and attributes. Callers hold + i_rwsem exclusive. If unset, then fall back to f_op->ioctl(). + The Address Space Object ========================fs/ioctl.c +185
-0@@ -19,6 +19,9 @@#include <linux/falloc.h> #include <linux/sched/signal.h> #include <linux/fiemap.h> +#include <linux/mount.h> +#include <linux/fscrypt.h> +#include <linux/miscattr.h> #include "internal.h" @@ -657,6 +660,311 @@ static int ioctl_file_dedupe_range(struct file *file,return ret; } +/** +* miscattr_fill_xflags - initialize miscattr with xflags +* @ma: miscattr pointer +* @xflags: FS_XFLAG_* flags +* +* Set ->fsx_xflags, ->xattr_valid and ->flags (translated xflags). All +* other fields are zeroed. +*/ +void miscattr_fill_xflags (struct miscattr *ma,u32 xflags) +{ +memset (ma,0 ,sizeof (*ma)); + ma->xattr_valid = true; + ma->fsx_xflags = xflags; +if (ma->fsx_xflags &FS_XFLAG_IMMUTABLE ) + ma->flags |=FS_IMMUTABLE_FL ; +if (ma->fsx_xflags &FS_XFLAG_APPEND ) + ma->flags |=FS_APPEND_FL ; +if (ma->fsx_xflags &FS_XFLAG_SYNC ) + ma->flags |=FS_SYNC_FL ; +if (ma->fsx_xflags &FS_XFLAG_NOATIME ) + ma->flags |=FS_NOATIME_FL ; +if (ma->fsx_xflags &FS_XFLAG_NODUMP ) + ma->flags |=FS_NODUMP_FL ; +if (ma->fsx_xflags &FS_XFLAG_DAX ) + ma->flags |=FS_DAX_FL ; +if (ma->fsx_xflags &FS_XFLAG_PROJINHERIT ) + ma->flags |=FS_PROJINHERIT_FL ; +} +EXPORT_SYMBOL (miscattr_fill_xflags); + +/** +* miscattr_fill_flags - initialize miscattr with flags +* @ma: miscattr pointer +* @flags: FS_*_FL flags +* +* Set ->flags, ->flags_valid and ->fsx_xflags (translated flags). +* All other fields are zeroed. +*/ +void miscattr_fill_flags (struct miscattr *ma,u32 flags) +{ +memset (ma,0 ,sizeof (*ma)); + ma->flags_valid = true; + ma->flags = flags; +if (ma->flags &FS_SYNC_FL ) + ma->fsx_xflags |=FS_XFLAG_SYNC ; +if (ma->flags &FS_IMMUTABLE_FL ) + ma->fsx_xflags |=FS_XFLAG_IMMUTABLE ; +if (ma->flags &FS_APPEND_FL ) + ma->fsx_xflags |=FS_XFLAG_APPEND ; +if (ma->flags &FS_NODUMP_FL ) + ma->fsx_xflags |=FS_XFLAG_NODUMP ; +if (ma->flags &FS_NOATIME_FL ) + ma->fsx_xflags |=FS_XFLAG_NOATIME ; +if (ma->flags &FS_DAX_FL ) + ma->fsx_xflags |=FS_XFLAG_DAX ; +if (ma->flags &FS_PROJINHERIT_FL ) + ma->fsx_xflags |=FS_XFLAG_PROJINHERIT ; +} +EXPORT_SYMBOL (miscattr_fill_flags); + +/** +* vfs_miscattr_get - retrieve miscellaneous inode attributes +* @dentry: the object to retrieve from +* @ma: miscattr pointer +* +* Call i_op->miscattr_get() callback, if exists. +* +* Returns 0 on success, or a negative error on failure. +*/ +int vfs_miscattr_get (struct dentry *dentry,struct miscattr *ma) +{ +struct inode *inode =d_inode (dentry); + +if (d_is_special (dentry)) +return -ENOTTY ; + +if (!inode->i_op->miscattr_get) +return -ENOIOCTLCMD ; + +return inode->i_op->miscattr_get (dentry, ma); +} +EXPORT_SYMBOL (vfs_miscattr_get); + +/** +* fsxattr_copy_to_user - copy fsxattr to userspace. +* @ma: miscattr pointer +* @ufa: fsxattr user pointer +* +* Returns 0 on success, or -EFAULT on failure. +*/ +int fsxattr_copy_to_user (const struct miscattr *ma,struct fsxattr __user *ufa) +{ +struct fsxattr fa = { + .fsx_xflags = ma->fsx_xflags, + .fsx_extsize = ma->fsx_extsize, + .fsx_nextents = ma->fsx_nextents, + .fsx_projid = ma->fsx_projid, + .fsx_cowextsize = ma->fsx_cowextsize, + }; + +if (copy_to_user (ufa, &fa,sizeof (fa))) +return -EFAULT ; + +return 0 ; +} +EXPORT_SYMBOL (fsxattr_copy_to_user); + +static int fsxattr_copy_from_user (struct miscattr *ma, +struct fsxattr __user *ufa) +{ +struct fsxattr fa; + +if (copy_from_user (&fa, ufa,sizeof (fa))) +return -EFAULT ; + +miscattr_fill_xflags (ma, fa.fsx_xflags); + ma->fsx_extsize = fa.fsx_extsize; + ma->fsx_nextents = fa.fsx_nextents; + ma->fsx_projid = fa.fsx_projid; + ma->fsx_cowextsize = fa.fsx_cowextsize; + +return 0 ; +} + +/* +* Generic function to check FS_IOC_FSSETXATTR/FS_IOC_SETFLAGS values and reject +* any invalid configurations. +* +* Note: must be called with inode lock held. +*/ +static int miscattr_set_prepare (struct inode *inode, +const struct miscattr *old_ma, +struct miscattr *ma) +{ +int err; + +/* +* The IMMUTABLE and APPEND_ONLY flags can only be changed by +* the relevant capability. +*/ +if ((ma->flags ^ old_ma->flags) & (FS_APPEND_FL |FS_IMMUTABLE_FL ) && + !capable (CAP_LINUX_IMMUTABLE )) +return -EPERM ; + + err =fscrypt_prepare_setflags (inode, old_ma->flags, ma->flags); +if (err) +return err; + +/* +* Project Quota ID state is only allowed to change from within the init +* namespace. Enforce that restriction only if we are trying to change +* the quota ID state. Everything else is allowed in user namespaces. +*/ +if (current_user_ns () != &init_user_ns) { +if (old_ma->fsx_projid != ma->fsx_projid) +return -EINVAL ; +if ((old_ma->fsx_xflags ^ ma->fsx_xflags) & +FS_XFLAG_PROJINHERIT ) +return -EINVAL ; + } + +/* Check extent size hints. */ +if ((ma->fsx_xflags &FS_XFLAG_EXTSIZE ) && !S_ISREG (inode->i_mode)) +return -EINVAL ; + +if ((ma->fsx_xflags &FS_XFLAG_EXTSZINHERIT ) && + !S_ISDIR (inode->i_mode)) +return -EINVAL ; + +if ((ma->fsx_xflags &FS_XFLAG_COWEXTSIZE ) && + !S_ISREG (inode->i_mode) && !S_ISDIR (inode->i_mode)) +return -EINVAL ; + +/* +* It is only valid to set the DAX flag on regular files and +* directories on filesystems. +*/ +if ((ma->fsx_xflags &FS_XFLAG_DAX ) && + !(S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode))) +return -EINVAL ; + +/* Extent size hints of zero turn off the flags. */
fs/ioctl.c static int ioctl_file_dedupe_range(struct file *file, · line 854
Quoted 10 lines
fs/ioctl.c +10
-0+if (ma->fsx_extsize ==0 ) + ma->fsx_xflags &= ~(FS_XFLAG_EXTSIZE |FS_XFLAG_EXTSZINHERIT ); +if (ma->fsx_cowextsize ==0 ) + ma->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE ; + +return 0 ; +} + +/** +* vfs_miscattr_set - change miscellaneous inode attributes
I think this misses to document the @mnt_userns argument probably just caused by the rebase.
fs/ioctl.c static int ioctl_file_dedupe_range(struct file *file, · line 866
Quoted 13 lines
fs/ioctl.c +12
-0+* @dentry: the object to change +* @ma: miscattr pointer +* +* After verifying permissions, call i_op->miscattr_set() callback, if +* exists. +* +* Verifying attributes involves retrieving current attributes with +* i_op->miscattr_get(), this also allows initilaizing attributes that have +* not been set by the caller to current values. Inode lock is held +* thoughout to prevent racing with another instance. +* +* Returns 0 on success, or a negative error on failure.
Fwiw, just because Willy made me aware of this, adding a ":" after the Return will make kernel-doc generate a separate return value section. It might also complain otherwise.
Christian
Quoted 39 lines
fs/ioctl.c +39
-0+*/ +int vfs_miscattr_set (struct user_namespace *mnt_userns,struct dentry *dentry, +struct miscattr *ma) +{ +struct inode *inode =d_inode (dentry); +struct miscattr old_ma = {}; +int err; + +if (d_is_special (dentry)) +return -ENOTTY ; + +if (!inode->i_op->miscattr_set) +return -ENOIOCTLCMD ; + +if (!inode_owner_or_capable (mnt_userns, inode)) +return -EPERM ; + +inode_lock (inode); + err =vfs_miscattr_get (dentry, &old_ma); +if (!err) { +/* initialize missing bits from old_ma */ +if (ma->flags_valid) { + ma->fsx_xflags |= old_ma.fsx_xflags & ~FS_XFLAG_COMMON ; + ma->fsx_extsize = old_ma.fsx_extsize; + ma->fsx_nextents = old_ma.fsx_nextents; + ma->fsx_projid = old_ma.fsx_projid; + ma->fsx_cowextsize = old_ma.fsx_cowextsize; + }else { + ma->flags |= old_ma.flags & ~FS_COMMON_FL ; + } + err =miscattr_set_prepare (inode, &old_ma, ma); +if (!err) + err = inode->i_op->miscattr_set (mnt_userns, dentry, ma); + } +inode_unlock (inode); + +return err; +} +EXPORT_SYMBOL (vfs_miscattr_set);
PATCH v2 2/18 ecryptfs: stack miscattr ops
In reply to Miklos SzerediAdd stacking for the miscattr operations.
--- fs/ecryptfs/inode.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
fs/ecryptfs/inode.c +22 -0
@@ -18,6 +18,7 @@#include <linux/fs_stack.h> #include <linux/slab.h> #include <linux/xattr.h> +#include <linux/miscattr.h> #include <asm/unaligned.h> #include "ecryptfs_kernel.h"
@@ -1118,6 +1119,23 @@ static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,return rc; } +static int ecryptfs_miscattr_get (struct dentry *dentry,struct miscattr *ma) +{ +return vfs_miscattr_get (ecryptfs_dentry_to_lower (dentry), ma); +} + +static int ecryptfs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma) +{ +struct dentry *lower_dentry =ecryptfs_dentry_to_lower (dentry); +int rc; + + rc =vfs_miscattr_set (&init_user_ns, lower_dentry, ma); +fsstack_copy_attr_all (d_inode (dentry),d_inode (lower_dentry)); + +return rc; +} +const struct inode_operations ecryptfs_symlink_iops = { .get_link = ecryptfs_get_link, .permission = ecryptfs_permission,
@@ -1139,6 +1157,8 @@ const struct inode_operations ecryptfs_dir_iops = { .permission = ecryptfs_permission, .setattr = ecryptfs_setattr, .listxattr = ecryptfs_listxattr, + .miscattr_get = ecryptfs_miscattr_get, + .miscattr_set = ecryptfs_miscattr_set, };const struct inode_operations ecryptfs_main_iops = {
@@ -1146,6 +1166,8 @@ const struct inode_operations ecryptfs_main_iops = { .setattr = ecryptfs_setattr, .getattr = ecryptfs_getattr, .listxattr = ecryptfs_listxattr, + .miscattr_get = ecryptfs_miscattr_get, + .miscattr_set = ecryptfs_miscattr_set, }; static int ecryptfs_xattr_get(const struct xattr_handler *handler,
Signature · 1 line
2.30.2
PATCH v2 3/18 ovl: stack miscattr ops
In reply to Miklos SzerediAdd stacking for the miscattr operations.
Add hack for calling security_file_ioctl() for now. Probably better to have a pair of specific hooks for these operations.
--- fs/overlayfs/dir.c | 2 ++ fs/overlayfs/inode.c | 77 ++++++++++++++++++++++++++++++++++++++++ fs/overlayfs/overlayfs.h | 3 ++ 3 files changed, 82 insertions(+)
fs/overlayfs/dir.c +2 -0
@@ -1301,4 +1301,6 @@ const struct inode_operations ovl_dir_inode_operations = { .listxattr = ovl_listxattr, .get_acl = ovl_get_acl, .update_time = ovl_update_time, + .miscattr_get = ovl_miscattr_get, + .miscattr_set = ovl_miscattr_set, };
fs/overlayfs/inode.c +77 -0
95 lines not on this page · raw message
fs/overlayfs/overlayfs.h +3 -0
@@ -521,6 +521,9 @@ int __init ovl_aio_request_cache_init(void);void ovl_aio_request_cache_destroy (void );long ovl_ioctl (struct file *file,unsigned int cmd,unsigned long arg);long ovl_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg); +int ovl_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int ovl_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);/* copy_up.c */ int ovl_copy_up (struct dentry *dentry);
Signature · 1 line
2.30.2
Al Viro
maintainerRe: [PATCH v2 03/18] ovl: stack miscattr ops
Quoted 17 lines · Miklos Szeredi
fs/overlayfs/inode.c +17
-0+int ovl_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma) +{ +struct inode *inode =d_inode (dentry); +struct dentry *upperdentry; +const struct cred *old_cred; +int err; + + err =ovl_want_write (dentry); +if (err) + goto out; + + err =ovl_copy_up (dentry); +if (!err) { + upperdentry =ovl_dentry_upper (dentry); + + old_cred =ovl_override_creds (inode->i_sb);
fs/overlayfs/inode.c static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, · line 560
Quoted 10 lines
fs/overlayfs/inode.c +10
-0+ err =ovl_security_miscattr (dentry, ma, true); +if (!err) + err =vfs_miscattr_set (&init_user_ns, upperdentry, ma); +revert_creds (old_cred); +ovl_copyflags (ovl_inode_real (inode), inode); + } +ovl_drop_write (dentry); +out: +return err; +}
Umm... No equivalents of
/*
* Prevent copy up if immutable and has no CAP_LINUX_IMMUTABLE
* capability.
*/
ret = -EPERM;
if (!ovl_has_upperdata(inode) && IS_IMMUTABLE(inode) &&
!capable(CAP_LINUX_IMMUTABLE))
goto unlock;
ret = ovl_maybe_copy_up(file_dentry(file), O_WRONLY);
if (ret)
goto unlock;in the current tree?
Al Viro
maintainerRe: [PATCH v2 03/18] ovl: stack miscattr ops
Quoted 12 lines · Al Viro
On Mon, Mar 22, 2021 at 03:49:01PM +0100, Miklos Szeredi wrote:
Umm... No equivalents of
/* * Prevent copy up if immutable and has no CAP_LINUX_IMMUTABLE * capability. */ ret = -EPERM; if (!ovl_has_upperdata(inode) && IS_IMMUTABLE(inode) && !capable(CAP_LINUX_IMMUTABLE)) goto unlock;
Nevermind, you take care of that in the caller...
PATCH v2 4/18 btrfs: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/btrfs/ctree.h | 3 + fs/btrfs/inode.c | 4 + fs/btrfs/ioctl.c | 249 +++++++++-------------------------------------- 3 files changed, 52 insertions(+), 204 deletions(-)
fs/btrfs/ctree.h +3 -0
@@ -3184,6 +3184,9 @@ void btrfs_update_inode_bytes(struct btrfs_inode *inode,/* ioctl.c */ long btrfs_ioctl (struct file *file,unsigned int cmd,unsigned long arg);long btrfs_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg); +int btrfs_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int btrfs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);int btrfs_ioctl_get_supported_features (void __user *arg);void btrfs_sync_inode_flags_to_i_flags (struct inode *inode);int __pure btrfs_is_empty_uuid (u8 *uuid);
fs/btrfs/inode.c +4 -0
@@ -10556,6 +10556,8 @@ static const struct inode_operations btrfs_dir_inode_operations = { .set_acl = btrfs_set_acl, .update_time = btrfs_update_time, .tmpfile = btrfs_tmpfile, + .miscattr_get = btrfs_miscattr_get, + .miscattr_set = btrfs_miscattr_set, };static const struct file_operations btrfs_dir_file_operations = {
@@ -10609,6 +10611,8 @@ static const struct inode_operations btrfs_file_inode_operations = { .get_acl = btrfs_get_acl, .set_acl = btrfs_set_acl, .update_time = btrfs_update_time, + .miscattr_get = btrfs_miscattr_get, + .miscattr_set = btrfs_miscattr_set, };static const struct inode_operations btrfs_special_inode_operations = { .getattr = btrfs_getattr,
fs/btrfs/ioctl.c +45 -204
332 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH v2 04/18] btrfs: convert to miscattr
Quoted 83 lines · Miklos Szeredi
Use the miscattr API to let the VFS handle locking, permission checking and conversion.
Signed-off-by Miklos Szeredi <[email protected]>Cc David Sterba <[email protected]>--- fs/btrfs/ctree.h | 3 + fs/btrfs/inode.c | 4 + fs/btrfs/ioctl.c | 249 +++++++++-------------------------------------- 3 files changed, 52 insertions(+), 204 deletions(-)fs/btrfs/ctree.h +3
-0@@ -3184,6 +3184,9 @@ void btrfs_update_inode_bytes(struct btrfs_inode *inode,/* ioctl.c */ long btrfs_ioctl (struct file *file,unsigned int cmd,unsigned long arg);long btrfs_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg); +int btrfs_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int btrfs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);int btrfs_ioctl_get_supported_features (void __user *arg);void btrfs_sync_inode_flags_to_i_flags (struct inode *inode);int __pure btrfs_is_empty_uuid (u8 *uuid);fs/btrfs/inode.c +4
-0@@ -10556,6 +10556,8 @@ static const struct inode_operations btrfs_dir_inode_operations = { .set_acl = btrfs_set_acl, .update_time = btrfs_update_time, .tmpfile = btrfs_tmpfile, + .miscattr_get = btrfs_miscattr_get, + .miscattr_set = btrfs_miscattr_set, };static const struct file_operations btrfs_dir_file_operations = {@@ -10609,6 +10611,8 @@ static const struct inode_operations btrfs_file_inode_operations = { .get_acl = btrfs_get_acl, .set_acl = btrfs_set_acl, .update_time = btrfs_update_time, + .miscattr_get = btrfs_miscattr_get, + .miscattr_set = btrfs_miscattr_set, };static const struct inode_operations btrfs_special_inode_operations = { .getattr = btrfs_getattr,fs/btrfs/ioctl.c +3
-11@@ -26,6 +26,7 @@#include <linux/btrfs.h> #include <linux/uaccess.h> #include <linux/iversion.h> +#include <linux/miscattr.h> #include "ctree.h" #include "disk-io.h" #include "export.h" @@ -153,16 +154,6 @@ void btrfs_sync_inode_flags_to_i_flags(struct inode *inode) new_fl); } -static int btrfs_ioctl_getflags (struct file *file,void __user *arg) -{ -struct btrfs_inode *binode =BTRFS_I (file_inode (file)); -unsigned int flags =btrfs_inode_flags_to_fsflags (binode->flags); - -if (copy_to_user (arg, &flags,sizeof (flags))) -return -EFAULT ; -return 0 ; -} -/* * Check if @flags are a supported and valid set of FS_*_FL flags and that * the old and new flags are not conflicting @@ -201,9 +192,34 @@ static int check_fsflags_compatible(struct btrfs_fs_info *fs_info,return 0 ; } -static int btrfs_ioctl_setflags (struct file *file,void __user *arg) +bool btrfs_exclop_start (struct btrfs_fs_info *fs_info, +enum btrfs_exclusive_operation type)
fs/btrfs/ioctl.c static int check_fsflags_compatible(struct btrfs_fs_info *fs_info, · line 205
Quoted 10 lines
fs/btrfs/ioctl.c +8
-1{ -struct inode *inode =file_inode (file); +return !cmpxchg (&fs_info->exclusive_operation,BTRFS_EXCLOP_NONE , type); +} + +void btrfs_exclop_finish (struct btrfs_fs_info *fs_info) +{ +WRITE_ONCE (fs_info->exclusive_operation,BTRFS_EXCLOP_NONE ); +sysfs_notify (&fs_info->fs_devices->fsid_kobj,NULL ,"exclusive_operation" ); +}
This function is moved around for no reason, it's not relevant for the attributes in any way and is exported so there's no problem with visibility eg. due to being static.
Quoted 60 lines
fs/btrfs/ioctl.c +21
-18+/* +* Set flags/xflags from the internal inode flags. The remaining items of +* fsxattr are zeroed. +*/ +int btrfs_miscattr_get (struct dentry *dentry,struct miscattr *ma) +{ +struct btrfs_inode *binode =BTRFS_I (d_inode (dentry)); + +miscattr_fill_flags (ma,btrfs_inode_flags_to_fsflags (binode->flags)); +return 0 ; +} + +int btrfs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma) +{ +struct inode *inode =d_inode (dentry);struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_inode *binode =BTRFS_I (inode);struct btrfs_root *root = binode->root;@@ -213,34 +229,21 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)const char *comp =NULL ;u32 binode_flags; -if (!inode_owner_or_capable (&init_user_ns, inode)) -return -EPERM ; -if (btrfs_root_readonly (root))return -EROFS ; -if (copy_from_user (&fsflags, arg,sizeof (fsflags))) -return -EFAULT ; - - ret =mnt_want_write_file (file); -if (ret) -return ret; +if (miscattr_has_xattr (ma)) +return -EOPNOTSUPP ; -inode_lock (inode); - fsflags =btrfs_mask_fsflags_for_type (inode, fsflags); + fsflags =btrfs_mask_fsflags_for_type (inode, ma->flags); old_fsflags =btrfs_inode_flags_to_fsflags (binode->flags); - - ret =vfs_ioc_setflags_prepare (inode, old_fsflags, fsflags); -if (ret) - goto out_unlock; - ret =check_fsflags (old_fsflags, fsflags);if (ret) - goto out_unlock; +return ret; ret =check_fsflags_compatible (fs_info, fsflags);if (ret) - goto out_unlock; +return ret; binode_flags = binode->flags;if (fsflags &FS_SYNC_FL )
fs/btrfs/ioctl.c static int btrfs_ioctl_setflags(struct file *file, void __user *arg) · line 270
Quoted 5 lines
fs/btrfs/ioctl.c +2
-0@@ -263,6 +266,13 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) binode_flags |=BTRFS_INODE_NOATIME ; else binode_flags &= ~BTRFS_INODE_NOATIME; + +/* if coming from FS_IOC_FSSETXATTR then skip unconverted flags */
/* If coming from FS_IOC_FSSETXATTR then skip unconverted flags */
Quoted 85 lines
fs/btrfs/ioctl.c +10
-47+if (!ma->flags_valid) { + trans =btrfs_start_transaction (root,1 ); + goto update_flags; + } +if (fsflags &FS_DIRSYNC_FL ) binode_flags |=BTRFS_INODE_DIRSYNC ;else @@ -303,10 +313,8 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) binode_flags |=BTRFS_INODE_NOCOMPRESS ; }else if (fsflags &FS_COMPR_FL ) { -if (IS_SWAPFILE (inode)) { - ret = -ETXTBSY ; - goto out_unlock; - } +if (IS_SWAPFILE (inode)) +return -ETXTBSY ; binode_flags |=BTRFS_INODE_COMPRESS ; binode_flags &= ~BTRFS_INODE_NOCOMPRESS ;@@ -323,10 +331,8 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)* 2 for properties */ trans =btrfs_start_transaction (root,3 ); -if (IS_ERR (trans)) { - ret =PTR_ERR (trans); - goto out_unlock; - } +if (IS_ERR (trans)) +return PTR_ERR (trans);if (comp) { ret = btrfs_set_prop(trans, inode, "btrfs.compression", comp,@@ -344,6 +350,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) } } +update_flags: binode->flags = binode_flags;btrfs_sync_inode_flags_to_i_flags (inode);inode_inc_iversion (inode);@@ -352,158 +359,6 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) out_end_trans:btrfs_end_transaction (trans); - out_unlock: -inode_unlock (inode); -mnt_drop_write_file (file); -return ret; -} - -/* -* Translate btrfs internal inode flags to xflags as expected by the -* FS_IOC_FSGETXATT ioctl. Filter only the supported ones, unknown flags are -* silently dropped. -*/ -static unsigned int btrfs_inode_flags_to_xflags (unsigned int flags) -{ -unsigned int xflags =0 ; - -if (flags &BTRFS_INODE_APPEND ) - xflags |=FS_XFLAG_APPEND ; -if (flags &BTRFS_INODE_IMMUTABLE ) - xflags |=FS_XFLAG_IMMUTABLE ; -if (flags &BTRFS_INODE_NOATIME ) - xflags |=FS_XFLAG_NOATIME ; -if (flags &BTRFS_INODE_NODUMP ) - xflags |=FS_XFLAG_NODUMP ; -if (flags &BTRFS_INODE_SYNC ) - xflags |=FS_XFLAG_SYNC ; - -return xflags; -} - -/* Check if @flags are a supported and valid set of FS_XFLAGS_* flags */ -static int check_xflags (unsigned int flags) -{ -if (flags & ~(FS_XFLAG_APPEND |FS_XFLAG_IMMUTABLE |FS_XFLAG_NOATIME | -FS_XFLAG_NODUMP |FS_XFLAG_SYNC )) -return -EOPNOTSUPP ; -return 0 ; -} - -bool btrfs_exclop_start(struct btrfs_fs_info *fs_info,
fs/btrfs/ioctl.c static int btrfs_ioctl_setflags(struct file *file, void __user *arg) · line 403
Quoted 10 lines
fs/btrfs/ioctl.c +0
-10- enum btrfs_exclusive_operation type) -{ -return !cmpxchg (&fs_info->exclusive_operation,BTRFS_EXCLOP_NONE , type); -} - -void btrfs_exclop_finish (struct btrfs_fs_info *fs_info) -{ -WRITE_ONCE (fs_info->exclusive_operation,BTRFS_EXCLOP_NONE ); -sysfs_notify (&fs_info->fs_devices->fsid_kobj,NULL ,"exclusive_operation" ); -}
Same, btrfs_exclop_start and btrfs_exclop_finish are not relevant to the attributes.
Quoted 71 lines
fs/btrfs/ioctl.c +0
-71- -/* -* Set the xflags from the internal inode flags. The remaining items of fsxattr -* are zeroed. -*/ -static int btrfs_ioctl_fsgetxattr (struct file *file,void __user *arg) -{ -struct btrfs_inode *binode =BTRFS_I (file_inode (file)); -struct fsxattr fa; - -simple_fill_fsxattr (&fa,btrfs_inode_flags_to_xflags (binode->flags)); -if (copy_to_user (arg, &fa,sizeof (fa))) -return -EFAULT ; - -return 0 ; -} - -static int btrfs_ioctl_fssetxattr (struct file *file,void __user *arg) -{ -struct inode *inode =file_inode (file); -struct btrfs_inode *binode =BTRFS_I (inode); -struct btrfs_root *root = binode->root; -struct btrfs_trans_handle *trans; -struct fsxattr fa, old_fa; -unsigned old_flags; -unsigned old_i_flags; -int ret =0 ; - -if (!inode_owner_or_capable (&init_user_ns, inode)) -return -EPERM ; - -if (btrfs_root_readonly (root)) -return -EROFS ; - -if (copy_from_user (&fa, arg,sizeof (fa))) -return -EFAULT ; - - ret =check_xflags (fa.fsx_xflags); -if (ret) -return ret; - -if (fa.fsx_extsize !=0 || fa.fsx_projid !=0 || fa.fsx_cowextsize !=0 ) -return -EOPNOTSUPP ; - - ret =mnt_want_write_file (file); -if (ret) -return ret; - -inode_lock (inode); - - old_flags = binode->flags; - old_i_flags = inode->i_flags; - -simple_fill_fsxattr (&old_fa, -btrfs_inode_flags_to_xflags (binode->flags)); - ret =vfs_ioc_fssetxattr_check (inode, &old_fa, &fa); -if (ret) - goto out_unlock; - -if (fa.fsx_xflags &FS_XFLAG_SYNC ) - binode->flags |=BTRFS_INODE_SYNC ; -else - binode->flags &= ~BTRFS_INODE_SYNC ; -if (fa.fsx_xflags &FS_XFLAG_IMMUTABLE ) - binode->flags |=BTRFS_INODE_IMMUTABLE ; -else - binode->flags &= ~BTRFS_INODE_IMMUTABLE ; -if (fa.fsx_xflags &FS_XFLAG_APPEND ) - binode->flags |=BTRFS_INODE_APPEND ; -else - binode->flags &= ~BTRFS_INODE_APPEND ;
fs/btrfs/ioctl.c static int btrfs_ioctl_setflags(struct file *file, void __user *arg) · line 484
Quoted 10 lines
fs/btrfs/ioctl.c +0
-10-if (fa.fsx_xflags &FS_XFLAG_NODUMP ) - binode->flags |=BTRFS_INODE_NODUMP ; -else - binode->flags &= ~BTRFS_INODE_NODUMP ; -if (fa.fsx_xflags &FS_XFLAG_NOATIME ) - binode->flags |=BTRFS_INODE_NOATIME ; -else - binode->flags &= ~BTRFS_INODE_NOATIME ; - -/* 1 item for the inode */
This comment hasn't been copied to btrfs_miscattr_set where the transaction is started.
fs/btrfs/ioctl.c static int btrfs_ioctl_setflags(struct file *file, void __user *arg) · line 485
Quoted 1 line
fs/btrfs/ioctl.c +0
-1- trans =btrfs_start_transaction (root,1 );
Other than that it looks that the conversion is complete, but I'll do another review round once you send and update.
I think you should enhance description in each per-fs conversion so the patch is readable standalone, eg. mentioning that the miscattr API wraps all the other attributes, enumerate them and note that the specific code handling them is deleted. Thanks.
PATCH v2 5/18 ext2: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/ext2/ext2.h | 7 ++-- fs/ext2/file.c | 2 ++ fs/ext2/ioctl.c | 88 ++++++++++++++++++------------------------------- fs/ext2/namei.c | 2 ++ 4 files changed, 39 insertions(+), 60 deletions(-)
fs/ext2/ext2.h +3 -4
@@ -283,8 +283,6 @@ static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags)/* * ioctl commands */ -#define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS -#define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS#define EXT2_IOC_GETVERSION FS_IOC_GETVERSION#define EXT2_IOC_SETVERSION FS_IOC_SETVERSION#define EXT2_IOC_GETRSVSZ _IOR('f', 5, long)
@@ -293,8 +291,6 @@ static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags)/* * ioctl commands in 32 bit emulation */ -#define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS -#define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS#define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION#define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION
@@ -772,6 +768,9 @@ extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len);/* ioctl.c */ +extern int ext2_miscattr_get (struct dentry *dentry,struct miscattr *ma); +extern int ext2_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);extern long ext2_ioctl (struct file *,unsigned int ,unsigned long );extern long ext2_compat_ioctl (struct file *,unsigned int ,unsigned long );
fs/ext2/file.c +2 -0
@@ -204,4 +204,6 @@ const struct inode_operations ext2_file_inode_operations = { .get_acl = ext2_get_acl, .set_acl = ext2_set_acl, .fiemap = ext2_fiemap, + .miscattr_get = ext2_miscattr_get, + .miscattr_set = ext2_miscattr_set, };
fs/ext2/ioctl.c +32 -56
113 lines not on this page · raw message
fs/ext2/namei.c +2 -0
@@ -427,6 +427,8 @@ const struct inode_operations ext2_dir_inode_operations = { .get_acl = ext2_get_acl, .set_acl = ext2_set_acl, .tmpfile = ext2_tmpfile, + .miscattr_get = ext2_miscattr_get, + .miscattr_set = ext2_miscattr_set, };const struct inode_operations ext2_special_inode_operations = {
Signature · 1 line
2.30.2
PATCH v2 6/18 ext4: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/ext4/ext4.h | 12 +-- fs/ext4/file.c | 2 + fs/ext4/ioctl.c | 210 ++++++++++-------------------------------------- fs/ext4/namei.c | 2 + 4 files changed, 51 insertions(+), 175 deletions(-)
fs/ext4/ext4.h +3 -9
@@ -472,15 +472,6 @@ struct flex_groups { EXT4_VERITY_FL | \ EXT4_INLINE_DATA_FL) -/* Flags we can manipulate with through FS_IOC_FSSETXATTR */ -#define EXT4_FL_XFLAG_VISIBLE (EXT4_SYNC_FL | \ - EXT4_IMMUTABLE_FL | \ - EXT4_APPEND_FL | \ - EXT4_NODUMP_FL | \ - EXT4_NOATIME_FL | \ - EXT4_PROJINHERIT_FL | \ - EXT4_DAX_FL) -/* Flags that should be inherited by new inodes from their parent. */ #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\ EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
@@ -2925,6 +2916,9 @@ extern int ext4_ind_remove_space(handle_t *handle, struct inode *inode,/* ioctl.c */ extern long ext4_ioctl (struct file *,unsigned int ,unsigned long );extern long ext4_compat_ioctl (struct file *,unsigned int ,unsigned long ); +int ext4_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma); +int ext4_miscattr_get (struct dentry *dentry,struct miscattr *ma);extern void ext4_reset_inode_seed (struct inode *inode);/* migrate.c */
fs/ext4/file.c +2 -0
@@ -919,5 +919,7 @@ const struct inode_operations ext4_file_inode_operations = { .get_acl = ext4_get_acl, .set_acl = ext4_set_acl, .fiemap = ext4_fiemap, + .miscattr_get = ext4_miscattr_get, + .miscattr_set = ext4_miscattr_set, };
fs/ext4/ioctl.c +44 -166
283 lines not on this page · raw message
fs/ext4/namei.c +2 -0
@@ -4144,6 +4144,8 @@ const struct inode_operations ext4_dir_inode_operations = { .get_acl = ext4_get_acl, .set_acl = ext4_set_acl, .fiemap = ext4_fiemap, + .miscattr_get = ext4_miscattr_get, + .miscattr_set = ext4_miscattr_set, };const struct inode_operations ext4_special_inode_operations = {
Signature · 1 line
2.30.2
PATCH v2 7/18 f2fs: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/f2fs/f2fs.h | 3 + fs/f2fs/file.c | 213 ++++++++---------------------------------------- fs/f2fs/namei.c | 2 + 3 files changed, 40 insertions(+), 178 deletions(-)
fs/f2fs/f2fs.h +3 -0
@@ -3194,6 +3194,9 @@ int f2fs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,int f2fs_truncate_hole (struct inode *inode,pgoff_t pg_start,pgoff_t pg_end);void f2fs_truncate_data_blocks_range (struct dnode_of_data *dn,int count);int f2fs_precache_extents (struct inode *inode); +int f2fs_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int f2fs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);long f2fs_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);long f2fs_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg);int f2fs_transfer_project_quota (struct inode *inode,kprojid_t kprojid);
fs/f2fs/file.c +35 -178
293 lines not on this page · raw message
fs/f2fs/namei.c +2 -0
@@ -1327,6 +1327,8 @@ const struct inode_operations f2fs_dir_inode_operations = { .set_acl = f2fs_set_acl, .listxattr = f2fs_listxattr, .fiemap = f2fs_fiemap, + .miscattr_get = f2fs_miscattr_get, + .miscattr_set = f2fs_miscattr_set, };const struct inode_operations f2fs_symlink_inode_operations = {
Signature · 1 line
2.30.2
PATCH v2 8/18 gfs2: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/gfs2/file.c | 57 ++++++++++++------------------------------------- fs/gfs2/inode.c | 4 ++++ fs/gfs2/inode.h | 3 +++ 3 files changed, 21 insertions(+), 43 deletions(-)
fs/gfs2/file.c +14 -43
@@ -25,6 +25,7 @@#include <linux/dlm_plock.h> #include <linux/delay.h> #include <linux/backing-dev.h> +#include <linux/miscattr.h> #include "gfs2.h" #include "incore.h"
@@ -153,9 +154,9 @@ static inline u32 gfs2_gfsflags_to_fsflags(struct inode *inode, u32 gfsflags)return fsflags; } -static int gfs2_get_flags (struct file *filp,u32 __user *ptr) +int gfs2_miscattr_get (struct dentry *dentry,struct miscattr *ma) { -struct inode *inode =file_inode (filp); +struct inode *inode =d_inode (dentry);struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_holder gh;int error;
@@ -168,8 +169,7 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr) fsflags =gfs2_gfsflags_to_fsflags (inode, ip->i_diskflags); -if (put_user (fsflags, ptr)) - error = -EFAULT ; +miscattr_fill_flags (ma, fsflags);gfs2_glock_dq (&gh); out_uninit:
@@ -213,33 +213,19 @@ void gfs2_set_inode_flags(struct inode *inode)* @fsflags: The FS_* inode flags passed in * */ -static int do_gfs2_set_flags (struct file *filp,u32 reqflags,u32 mask, +static int do_gfs2_set_flags (struct inode *inode,u32 reqflags,u32 mask,const u32 fsflags) { -struct inode *inode =file_inode (filp);struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_sbd *sdp =GFS2_SB (inode);struct buffer_head *bh;struct gfs2_holder gh;int error; -u32 new_flags, flags, oldflags; - - error =mnt_want_write_file (filp); -if (error) -return error; +u32 new_flags, flags; error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh);if (error) - goto out_drop_write; - - oldflags =gfs2_gfsflags_to_fsflags (inode, ip->i_diskflags); - error =vfs_ioc_setflags_prepare (inode, oldflags, fsflags); -if (error) - goto out; - - error = -EACCES ; -if (!inode_owner_or_capable (&init_user_ns, inode)) - goto out; +return error; error =0 ; flags = ip->i_diskflags;
@@ -252,9 +238,6 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask, goto out;if (IS_APPEND (inode) && (new_flags &GFS2_DIF_APPENDONLY )) goto out; -if (((new_flags ^ flags) &GFS2_DIF_IMMUTABLE ) && - !capable (CAP_LINUX_IMMUTABLE )) - goto out;if (!IS_IMMUTABLE (inode)) { error =gfs2_permission (&init_user_ns, inode,MAY_WRITE );if (error)
@@ -291,20 +274,19 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask,gfs2_trans_end (sdp); out:gfs2_glock_dq_uninit (&gh); -out_drop_write: -mnt_drop_write_file (filp);return error; } -static int gfs2_set_flags (struct file *filp,u32 __user *ptr) +int gfs2_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma) { -struct inode *inode =file_inode (filp); -u32 fsflags, gfsflags =0 ; +struct inode *inode =d_inode (dentry); +u32 fsflags = ma->flags, gfsflags =0 ;u32 mask;int i; -if (get_user (fsflags, ptr)) -return -EFAULT ; +if (miscattr_has_xattr (ma)) +return -EOPNOTSUPP ;for (i =0 ; i <ARRAY_SIZE (fsflag_gfs2flag); i++) {if (fsflags & fsflag_gfs2flag[i].fsflag) {
@@ -325,7 +307,7 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr) mask &= ~(GFS2_DIF_TOPDIR |GFS2_DIF_INHERIT_JDATA ); } -return do_gfs2_set_flags (filp, gfsflags, mask, fsflags); +return do_gfs2_set_flags (inode, gfsflags, mask, fsflags); }static int gfs2_getlabel (struct file *filp,char __user *label)
@@ -342,10 +324,6 @@ static int gfs2_getlabel(struct file *filp, char __user *label)static long gfs2_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {switch (cmd) { -case FS_IOC_GETFLAGS : -return gfs2_get_flags (filp, (u32 __user *)arg); -case FS_IOC_SETFLAGS : -return gfs2_set_flags (filp, (u32 __user *)arg);case FITRIM :return gfs2_fitrim (filp, (void __user *)arg);case FS_IOC_GETFSLABEL :
@@ -359,13 +337,6 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)static long gfs2_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {switch (cmd) { -/* These are just misnamed, they actually get/put from/to user an int */ -case FS_IOC32_GETFLAGS : - cmd =FS_IOC_GETFLAGS ; -break ; -case FS_IOC32_SETFLAGS : - cmd =FS_IOC_SETFLAGS ; -break ;/* Keep this list in sync with gfs2_ioctl */ case FITRIM :case FS_IOC_GETFSLABEL :
fs/gfs2/inode.c +4 -0
@@ -2157,6 +2157,8 @@ static const struct inode_operations gfs2_file_iops = { .get_acl = gfs2_get_acl, .set_acl = gfs2_set_acl, .update_time = gfs2_update_time, + .miscattr_get = gfs2_miscattr_get, + .miscattr_set = gfs2_miscattr_set, };static const struct inode_operations gfs2_dir_iops = {
@@ -2178,6 +2180,8 @@ static const struct inode_operations gfs2_dir_iops = { .set_acl = gfs2_set_acl, .update_time = gfs2_update_time, .atomic_open = gfs2_atomic_open, + .miscattr_get = gfs2_miscattr_get, + .miscattr_set = gfs2_miscattr_set, };static const struct inode_operations gfs2_symlink_iops = {
fs/gfs2/inode.h +3 -0
@@ -111,6 +111,9 @@ extern loff_t gfs2_seek_hole(struct file *file, loff_t offset);extern const struct file_operations gfs2_file_fops_nolock;extern const struct file_operations gfs2_dir_fops_nolock; +extern int gfs2_miscattr_get (struct dentry *dentry,struct miscattr *ma); +extern int gfs2_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);extern void gfs2_set_inode_flags (struct inode *inode);#ifdef CONFIG_GFS2_FS_LOCKING_DLM
Signature · 1 line
2.30.2
PATCH v2 9/18 orangefs: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/orangefs/file.c | 79 --------------------------------------------- fs/orangefs/inode.c | 50 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 79 deletions(-)
fs/orangefs/file.c +0 -79
@@ -375,84 +375,6 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb,return ret; } -static int orangefs_getflags (struct inode *inode,unsigned long *uval) -{ -__u64 val =0 ; -int ret; - - ret =orangefs_inode_getxattr (inode, -"user.pvfs2.meta_hint" , - &val,sizeof (val)); -if (ret <0 && ret != -ENODATA ) -return ret; -else if (ret == -ENODATA ) - val =0 ; - *uval = val; -return 0 ; -} - -/* -* Perform a miscellaneous operation on a file. -*/ -static long orangefs_ioctl (struct file *file,unsigned int cmd,unsigned long arg) -{ -struct inode *inode =file_inode (file); -int ret = -ENOTTY ; -__u64 val =0 ; -unsigned long uval; - -gossip_debug (GOSSIP_FILE_DEBUG , -"orangefs_ioctl: called with cmd %d\n" , - cmd); - -/* -* we understand some general ioctls on files, such as the immutable -* and append flags -*/ -if (cmd ==FS_IOC_GETFLAGS ) { - ret =orangefs_getflags (inode, &uval); -if (ret) -return ret; -gossip_debug (GOSSIP_FILE_DEBUG , -"orangefs_ioctl: FS_IOC_GETFLAGS: %llu\n" , - (unsigned long long )uval); -return put_user (uval, (int __user *)arg); - }else if (cmd ==FS_IOC_SETFLAGS ) { -unsigned long old_uval; - - ret =0 ; -if (get_user (uval, (int __user *)arg)) -return -EFAULT ; -/* -* ORANGEFS_MIRROR_FL is set internally when the mirroring mode -* is turned on for a file. The user is not allowed to turn -* on this bit, but the bit is present if the user first gets -* the flags and then updates the flags with some new -* settings. So, we ignore it in the following edit. bligon. -*/ -if ((uval & ~ORANGEFS_MIRROR_FL ) & - (~(FS_IMMUTABLE_FL |FS_APPEND_FL |FS_NOATIME_FL ))) { -gossip_err ("orangefs_ioctl: the FS_IOC_SETFLAGS only supports setting one of FS_IMMUTABLE_FL|FS_APPEND_FL|FS_NOATIME_FL\n" ); -return -EINVAL ; - } - ret =orangefs_getflags (inode, &old_uval); -if (ret) -return ret; - ret =vfs_ioc_setflags_prepare (inode, old_uval, uval); -if (ret) -return ret; - val = uval; -gossip_debug (GOSSIP_FILE_DEBUG , -"orangefs_ioctl: FS_IOC_SETFLAGS: %llu\n" , - (unsigned long long )val); - ret =orangefs_inode_setxattr (inode, -"user.pvfs2.meta_hint" , - &val,sizeof (val),0 ); - } - -return ret; -} -static vm_fault_t orangefs_fault (struct vm_fault *vmf) {struct file *file = vmf->vma->vm_file;
@@ -657,7 +579,6 @@ const struct file_operations orangefs_file_operations = { .read_iter = orangefs_file_read_iter, .write_iter = orangefs_file_write_iter, .lock = orangefs_lock, - .unlocked_ioctl = orangefs_ioctl, .mmap = orangefs_file_mmap, .open = generic_file_open, .splice_read = generic_file_splice_read,
fs/orangefs/inode.c +50 -0
68 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v2 10/18 xfs: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/xfs/libxfs/xfs_fs.h | 4 - fs/xfs/xfs_ioctl.c | 316 ++++++++++++----------------------------- fs/xfs/xfs_ioctl.h | 11 ++ fs/xfs/xfs_ioctl32.c | 2 - fs/xfs/xfs_ioctl32.h | 2 - fs/xfs/xfs_iops.c | 7 + 6 files changed, 107 insertions(+), 235 deletions(-)
fs/xfs/libxfs/xfs_fs.h +0 -4
@@ -770,8 +770,6 @@ struct xfs_scrub_metadata {/* * ioctl commands that are used by Linux filesystems */ -#define XFS_IOC_GETXFLAGS FS_IOC_GETFLAGS -#define XFS_IOC_SETXFLAGS FS_IOC_SETFLAGS#define XFS_IOC_GETVERSION FS_IOC_GETVERSION/*
@@ -782,8 +780,6 @@ struct xfs_scrub_metadata {#define XFS_IOC_ALLOCSP _IOW ('X', 10, struct xfs_flock64)#define XFS_IOC_FREESP _IOW ('X', 11, struct xfs_flock64)#define XFS_IOC_DIOINFO _IOR ('X', 30, struct dioattr) -#define XFS_IOC_FSGETXATTR FS_IOC_FSGETXATTR -#define XFS_IOC_FSSETXATTR FS_IOC_FSSETXATTR#define XFS_IOC_ALLOCSP64 _IOW ('X', 36, struct xfs_flock64)#define XFS_IOC_FREESP64 _IOW ('X', 37, struct xfs_flock64)#define XFS_IOC_GETBMAP _IOWR('X', 38, struct getbmap)
fs/xfs/xfs_ioctl.c +89 -227
544 lines not on this page · raw message
fs/xfs/xfs_ioctl.h +11 -0
@@ -47,6 +47,17 @@ xfs_handle_to_dentry(void __user *uhandle, u32 hlen); +extern int +xfs_miscattr_get ( +struct dentry *dentry, +struct miscattr *ma); + +extern int +xfs_miscattr_set ( +struct user_namespace *mnt_userns, +struct dentry *dentry, +struct miscattr *ma); + extern long xfs_file_ioctl( struct file *filp,
fs/xfs/xfs_ioctl32.c +0 -2
@@ -484,8 +484,6 @@ xfs_file_compat_ioctl( }#endif /* long changes size, but xfs only copiese out 32 bits */ -case XFS_IOC_GETXFLAGS_32 : -case XFS_IOC_SETXFLAGS_32 :case XFS_IOC_GETVERSION_32 : cmd =_NATIVE_IOC (cmd, long);return xfs_file_ioctl (filp, cmd, p);
fs/xfs/xfs_ioctl32.h +0 -2
@@ -17,8 +17,6 @@*/ /* stock kernel-level ioctls we support */ -#define XFS_IOC_GETXFLAGS_32 FS_IOC32_GETFLAGS -#define XFS_IOC_SETXFLAGS_32 FS_IOC32_SETFLAGS#define XFS_IOC_GETVERSION_32 FS_IOC32_GETVERSION/*
fs/xfs/xfs_iops.c +7 -0
@@ -21,6 +21,7 @@#include "xfs_dir2.h" #include "xfs_iomap.h" #include "xfs_error.h" +#include "xfs_ioctl.h" #include <linux/posix_acl.h> #include <linux/security.h>
@@ -1152,6 +1153,8 @@ static const struct inode_operations xfs_inode_operations = { .listxattr = xfs_vn_listxattr, .fiemap = xfs_vn_fiemap, .update_time = xfs_vn_update_time, + .miscattr_get = xfs_miscattr_get, + .miscattr_set = xfs_miscattr_set, };static const struct inode_operations xfs_dir_inode_operations = {
@@ -1177,6 +1180,8 @@ static const struct inode_operations xfs_dir_inode_operations = { .listxattr = xfs_vn_listxattr, .update_time = xfs_vn_update_time, .tmpfile = xfs_vn_tmpfile, + .miscattr_get = xfs_miscattr_get, + .miscattr_set = xfs_miscattr_set, };static const struct inode_operations xfs_dir_ci_inode_operations = {
@@ -1202,6 +1207,8 @@ static const struct inode_operations xfs_dir_ci_inode_operations = { .listxattr = xfs_vn_listxattr, .update_time = xfs_vn_update_time, .tmpfile = xfs_vn_tmpfile, + .miscattr_get = xfs_miscattr_get, + .miscattr_set = xfs_miscattr_set, };static const struct inode_operations xfs_symlink_inode_operations = {
Signature · 1 line
2.30.2
Re: [PATCH v2 10/18] xfs: convert to miscattr
Quoted 108 lines · Miklos Szeredi
Use the miscattr API to let the VFS handle locking, permission checking and conversion.
Signed-off-by Miklos Szeredi <[email protected]>Cc Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_fs.h | 4 - fs/xfs/xfs_ioctl.c | 316 ++++++++++++----------------------------- fs/xfs/xfs_ioctl.h | 11 ++ fs/xfs/xfs_ioctl32.c | 2 - fs/xfs/xfs_ioctl32.h | 2 - fs/xfs/xfs_iops.c | 7 + 6 files changed, 107 insertions(+), 235 deletions(-)fs/xfs/libxfs/xfs_fs.h +0
-4@@ -770,8 +770,6 @@ struct xfs_scrub_metadata {/* * ioctl commands that are used by Linux filesystems */ -#define XFS_IOC_GETXFLAGS FS_IOC_GETFLAGS -#define XFS_IOC_SETXFLAGS FS_IOC_SETFLAGS#define XFS_IOC_GETVERSION FS_IOC_GETVERSION/* @@ -782,8 +780,6 @@ struct xfs_scrub_metadata {#define XFS_IOC_ALLOCSP _IOW ('X', 10, struct xfs_flock64)#define XFS_IOC_FREESP _IOW ('X', 11, struct xfs_flock64)#define XFS_IOC_DIOINFO _IOR ('X', 30, struct dioattr) -#define XFS_IOC_FSGETXATTR FS_IOC_FSGETXATTR -#define XFS_IOC_FSSETXATTR FS_IOC_FSSETXATTR#define XFS_IOC_ALLOCSP64 _IOW ('X', 36, struct xfs_flock64)#define XFS_IOC_FREESP64 _IOW ('X', 37, struct xfs_flock64)#define XFS_IOC_GETBMAP _IOWR('X', 38, struct getbmap)fs/xfs/xfs_ioctl.c +1
-56@@ -40,6 +40,7 @@#include <linux/mount.h> #include <linux/namei.h> +#include <linux/miscattr.h> /* * xfs_find_handle maps from userspace xfs_fsop_handlereq structure to @@ -1053,97 +1054,51 @@ xfs_ioc_ag_geometry(* Linux extended inode flags interface. */ -STATIC unsigned int -xfs_merge_ioc_xflags ( -unsigned int flags, -unsigned int start) -{ -unsigned int xflags = start; - -if (flags &FS_IMMUTABLE_FL ) - xflags |=FS_XFLAG_IMMUTABLE ; -else - xflags &= ~FS_XFLAG_IMMUTABLE ; -if (flags &FS_APPEND_FL ) - xflags |=FS_XFLAG_APPEND ; -else - xflags &= ~FS_XFLAG_APPEND ; -if (flags &FS_SYNC_FL ) - xflags |=FS_XFLAG_SYNC ; -else - xflags &= ~FS_XFLAG_SYNC ; -if (flags &FS_NOATIME_FL ) - xflags |=FS_XFLAG_NOATIME ; -else - xflags &= ~FS_XFLAG_NOATIME ; -if (flags &FS_NODUMP_FL ) - xflags |=FS_XFLAG_NODUMP ; -else - xflags &= ~FS_XFLAG_NODUMP ; -if (flags &FS_DAX_FL ) - xflags |=FS_XFLAG_DAX ; -else - xflags &= ~FS_XFLAG_DAX ; - -return xflags; -} - -STATIC unsigned int -xfs_di2lxflags ( -uint16_t di_flags, -uint64_t di_flags2) -{ -unsigned int flags =0 ; - -if (di_flags &XFS_DIFLAG_IMMUTABLE ) - flags |=FS_IMMUTABLE_FL ; -if (di_flags &XFS_DIFLAG_APPEND ) - flags |=FS_APPEND_FL ; -if (di_flags &XFS_DIFLAG_SYNC ) - flags |=FS_SYNC_FL ; -if (di_flags &XFS_DIFLAG_NOATIME ) - flags |=FS_NOATIME_FL ; -if (di_flags &XFS_DIFLAG_NODUMP ) - flags |=FS_NODUMP_FL ; -if (di_flags2 &XFS_DIFLAG2_DAX ) { - flags |=FS_DAX_FL ; - } -return flags;
fs/xfs/xfs_ioctl.c xfs_ioc_ag_geometry( · line 1063
Quoted 10 lines
fs/xfs/xfs_ioctl.c +1
-3-} -static void xfs_fill_fsxattr (struct xfs_inode *ip,bool attr, -struct fsxattr *fa) +struct miscattr *ma) {struct xfs_ifork *ifp = attr ? ip->i_afp : &ip->i_df;
Hm, could you replace "bool attr" with "int whichfork"? The new signature and first line of code becomes:
static void
xfs_fill_fsxattr(
struct xfs_inode *ip,
int whichfork,
struct miscattr *ma)
{
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);...and then the two wrappers of xfs_fill_fsxattr become:
STATIC int
xfs_ioc_fsgetxattra(
struct xfs_inode *ip,
void __user *arg)
{
struct miscattr ma;
xfs_ilock(ip, XFS_ILOCK_SHARED);
xfs_fill_fsxattr(ip, XFS_ATTR_FORK, &ma);
xfs_iunlock(ip, XFS_ILOCK_SHARED);
return fsxattr_copy_to_user(&ma, arg);
}int
xfs_miscattr_get(
struct dentry *dentry,
struct miscattr *ma)
{
struct xfs_inode *ip = XFS_I(d_inode(dentry));
xfs_ilock(ip, XFS_ILOCK_SHARED);
xfs_fill_fsxattr(ip, XFS_DATA_FORK, ma);
xfs_iunlock(ip, XFS_ILOCK_SHARED);
return 0;
}This makes it clearer that FSGETXATTRA reports on the extended attributes fork, and regular GETFLAGS/FSGETXATTR reports on the data fork.
fs/xfs/xfs_ioctl.c xfs_ioc_ag_geometry( · line 1066
Quoted 5 lines
fs/xfs/xfs_ioctl.c +2
-3-simple_fill_fsxattr (fa,xfs_ip2xflags (ip)); - fa->fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog; - fa->fsx_cowextsize = ip->i_d.di_cowextsize << +miscattr_fill_xflags (ma,xfs_ip2xflags (ip)); + ma->flags &= ~FS_PROJINHERIT_FL ;/* Accidental? */
Yes, this was an oversight when ext4/f2fs added PROJINHERIT_FL.
Quoted 27 lines
fs/xfs/xfs_ioctl.c +9
-7+ ma->fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog; + ma->fsx_cowextsize = ip->i_d.di_cowextsize << ip->i_mount->m_sb.sb_blocklog; - fa->fsx_projid = ip->i_d.di_projid; + ma->fsx_projid = ip->i_d.di_projid;if (ifp && (ifp->if_flags &XFS_IFEXTENTS )) - fa->fsx_nextents =xfs_iext_count (ifp); + ma->fsx_nextents =xfs_iext_count (ifp);else - fa->fsx_nextents =xfs_ifork_nextents (ifp); + ma->fsx_nextents =xfs_ifork_nextents (ifp); } STATIC int -xfs_ioc_fsgetxattr ( +xfs_ioc_fsgetxattra (xfs_inode_t *ip, -int attr,void __user *arg) { -struct fsxattr fa; +struct miscattr ma;xfs_ilock (ip,XFS_ILOCK_SHARED ); -xfs_fill_fsxattr (ip, attr, &fa); +xfs_fill_fsxattr (ip, true, &ma); +xfs_iunlock (ip,XFS_ILOCK_SHARED );
fs/xfs/xfs_ioctl.c xfs_ioc_ag_geometry( · line 1096
Quoted 10 lines
fs/xfs/xfs_ioctl.c +10
-0+ +return fsxattr_copy_to_user (&ma, arg); +} + +int +xfs_miscattr_get ( +struct dentry *dentry, +struct miscattr *ma) +{ +xfs_inode_t *ip =XFS_I (d_inode (dentry));
Please don't use struct typedefs. We're trying to get rid of these.
struct xfs_inode *ip = XFS_I(...);
Quoted 217 lines
fs/xfs/xfs_ioctl.c +36
-44+ +xfs_ilock (ip,XFS_ILOCK_SHARED ); +xfs_fill_fsxattr (ip, false, ma);xfs_iunlock (ip,XFS_ILOCK_SHARED ); -if (copy_to_user (arg, &fa,sizeof (fa))) -return -EFAULT ;return 0 ; }@@ -1210,37 +1165,37 @@ static intxfs_ioctl_setattr_xflags ( struct xfs_trans *tp, struct xfs_inode *ip, - struct fsxattr *fa) + struct miscattr *ma) { struct xfs_mount *mp = ip->i_mount;uint64_t di_flags2;/* Can't change realtime flag if any extents are allocated. */ if ((ip->i_df.if_nextents || ip->i_delayed_blks) && -XFS_IS_REALTIME_INODE (ip) != (fa->fsx_xflags &FS_XFLAG_REALTIME )) +XFS_IS_REALTIME_INODE (ip) != (ma->fsx_xflags &FS_XFLAG_REALTIME ))return -EINVAL ;/* If realtime flag is set then must have realtime device */ -if (fa->fsx_xflags &FS_XFLAG_REALTIME ) { +if (ma->fsx_xflags &FS_XFLAG_REALTIME ) {if (mp->m_sb.sb_rblocks ==0 || mp->m_sb.sb_rextsize ==0 || (ip->i_d.di_extsize % mp->m_sb.sb_rextsize))return -EINVAL ; }/* Clear reflink if we are actually able to set the rt flag. */ -if ((fa->fsx_xflags &FS_XFLAG_REALTIME ) &&xfs_is_reflink_inode (ip)) +if ((ma->fsx_xflags &FS_XFLAG_REALTIME ) &&xfs_is_reflink_inode (ip)) ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK ;/* Don't allow us to set DAX mode for a reflinked file for now. */ -if ((fa->fsx_xflags &FS_XFLAG_DAX ) &&xfs_is_reflink_inode (ip)) +if ((ma->fsx_xflags &FS_XFLAG_DAX ) &&xfs_is_reflink_inode (ip))return -EINVAL ;/* diflags2 only valid for v3 inodes. */ - di_flags2 =xfs_flags2diflags2 (ip, fa->fsx_xflags); + di_flags2 =xfs_flags2diflags2 (ip, ma->fsx_xflags);if (di_flags2 && !xfs_sb_version_has_v3inode (&mp->m_sb))return -EINVAL ; - ip->i_d.di_flags =xfs_flags2diflags (ip, fa->fsx_xflags); + ip->i_d.di_flags =xfs_flags2diflags (ip, ma->fsx_xflags); ip->i_d.di_flags2 = di_flags2;xfs_diflags_to_iflags (ip, false);@@ -1253,7 +1208,7 @@ xfs_ioctl_setattr_xflags(static void xfs_ioctl_setattr_prepare_dax (struct xfs_inode *ip, -struct fsxattr *fa) +struct miscattr *ma) {struct xfs_mount *mp = ip->i_mount;struct inode *inode =VFS_I (ip);@@ -1265,9 +1220,9 @@ xfs_ioctl_setattr_prepare_dax( (mp->m_flags & XFS_MOUNT_DAX_NEVER))return ; -if (((fa->fsx_xflags &FS_XFLAG_DAX ) && +if (((ma->fsx_xflags &FS_XFLAG_DAX ) && !(ip->i_d.di_flags2 &XFS_DIFLAG2_DAX )) || - (!(fa->fsx_xflags &FS_XFLAG_DAX ) && + (!(ma->fsx_xflags &FS_XFLAG_DAX ) && (ip->i_d.di_flags2 &XFS_DIFLAG2_DAX )))d_mark_dontcache (inode); }@@ -1280,10 +1235,9 @@ xfs_ioctl_setattr_prepare_dax(*/ static struct xfs_trans *xfs_ioctl_setattr_get_trans ( -struct file *file, +struct xfs_inode *ip,struct xfs_dquot *pdqp) { -struct xfs_inode *ip =XFS_I (file_inode (file));struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp;int error = -EROFS ;@@ -1299,24 +1253,11 @@ xfs_ioctl_setattr_get_trans(if (error) goto out_error; -/* -* CAP_FOWNER overrides the following restrictions: -* -* The user ID of the calling process must be equal to the file owner -* ID, except in cases where the CAP_FSETID capability is applicable. -*/ -if (!inode_owner_or_capable (file_mnt_user_ns (file),VFS_I (ip))) { - error = -EPERM ; - goto out_cancel; - } -if (mp->m_flags &XFS_MOUNT_WSYNC )xfs_trans_set_sync (tp);return tp; -out_cancel: -xfs_trans_cancel (tp); out_error:return ERR_PTR (error); }@@ -1340,25 +1281,28 @@ xfs_ioctl_setattr_get_trans(static int xfs_ioctl_setattr_check_extsize (struct xfs_inode *ip, -struct fsxattr *fa) +struct miscattr *ma) {struct xfs_mount *mp = ip->i_mount;xfs_extlen_t size;xfs_fsblock_t extsize_fsb; +if (!ma->xattr_valid) +return 0 ; +if (S_ISREG (VFS_I (ip)->i_mode) && ip->i_df.if_nextents && - ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != fa->fsx_extsize)) + ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != ma->fsx_extsize))return -EINVAL ; -if (fa->fsx_extsize ==0 ) +if (ma->fsx_extsize ==0 )return 0 ; - extsize_fsb =XFS_B_TO_FSB (mp, fa->fsx_extsize); + extsize_fsb =XFS_B_TO_FSB (mp, ma->fsx_extsize);if (extsize_fsb >MAXEXTLEN )return -EINVAL ;if (XFS_IS_REALTIME_INODE (ip) || - (fa->fsx_xflags &FS_XFLAG_REALTIME )) { + (ma->fsx_xflags &FS_XFLAG_REALTIME )) { size = mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog; }else { size = mp->m_sb.sb_blocksize;@@ -1366,7 +1310,7 @@ xfs_ioctl_setattr_check_extsize(return -EINVAL ; } -if (fa->fsx_extsize % size) +if (ma->fsx_extsize % size)return -EINVAL ;return 0 ;@@ -1390,22 +1334,25 @@ xfs_ioctl_setattr_check_extsize(static int xfs_ioctl_setattr_check_cowextsize (struct xfs_inode *ip, -struct fsxattr *fa) +struct miscattr *ma) {struct xfs_mount *mp = ip->i_mount;xfs_extlen_t size;xfs_fsblock_t cowextsize_fsb; -if (!(fa->fsx_xflags &FS_XFLAG_COWEXTSIZE )) +if (!ma->xattr_valid) +return 0 ; + +if (!(ma->fsx_xflags &FS_XFLAG_COWEXTSIZE ))return 0 ;if (!xfs_sb_version_hasreflink (&ip->i_mount->m_sb))return -EINVAL ; -if (fa->fsx_cowextsize ==0 ) +if (ma->fsx_cowextsize ==0 )return 0 ; - cowextsize_fsb =XFS_B_TO_FSB (mp, fa->fsx_cowextsize); + cowextsize_fsb =XFS_B_TO_FSB (mp, ma->fsx_cowextsize);if (cowextsize_fsb >MAXEXTLEN )return -EINVAL ;@@ -1413,7 +1360,7 @@ xfs_ioctl_setattr_check_cowextsize(if (cowextsize_fsb > mp->m_sb.sb_agblocks /2 )return -EINVAL ; -if (fa->fsx_cowextsize % size) +if (ma->fsx_cowextsize % size)return -EINVAL ;return 0 ;@@ -1422,23 +1369,25 @@ xfs_ioctl_setattr_check_cowextsize(static int xfs_ioctl_setattr_check_projid (struct xfs_inode *ip, -struct fsxattr *fa) +struct miscattr *ma) { +if (!ma->xattr_valid) +return 0 ; +/* Disallow 32bit project ids if projid32bit feature is not enabled. */ -if (fa->fsx_projid > (uint16_t )-1 && +if (ma->fsx_projid > (uint16_t )-1 && !xfs_sb_version_hasprojid32bit (&ip->i_mount->m_sb))return -EINVAL ;return 0 ; } -STATIC int -xfs_ioctl_setattr ( -struct file *file, -struct fsxattr *fa)
fs/xfs/xfs_ioctl.c xfs_ioctl_setattr_check_cowextsize( · line 1390
Quoted 10 lines
fs/xfs/xfs_ioctl.c +6
-3+int +xfs_miscattr_set ( +struct user_namespace *mnt_userns, +struct dentry *dentry, +struct miscattr *ma) { -struct user_namespace *mnt_userns =file_mnt_user_ns (file); -struct xfs_inode *ip =XFS_I (file_inode (file)); -struct fsxattr old_fa; +xfs_inode_t *ip =XFS_I (d_inode (dentry));
Same thing here about struct typedefs.
fs/xfs/xfs_ioctl.c xfs_ioctl_setattr( · line 1400
Quoted 10 lines
fs/xfs/xfs_ioctl.c +2
-1struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp;struct xfs_dquot *pdqp =NULL ;@@ -1447,7 +1396,15 @@ xfs_ioctl_setattr(trace_xfs_ioctl_setattr (ip); - error =xfs_ioctl_setattr_check_projid (ip, fa); +if (!ma->xattr_valid) { +/* FS_PROJINHERIT_FL not accepted, deliberate? */
No. I think this is an oversight from when ext4/f2fs added PROJINHERIT_FL and forgot to update XFS.
Quoted 19 lines
fs/xfs/xfs_ioctl.c +9
-2+if (ma->flags & ~(FS_IMMUTABLE_FL |FS_APPEND_FL | +FS_NOATIME_FL |FS_NODUMP_FL | +FS_SYNC_FL |FS_DAX_FL )) +return -EOPNOTSUPP ; + } + + error =xfs_ioctl_setattr_check_projid (ip, ma);if (error)return error;@@ -1459,39 +1416,36 @@ xfs_ioctl_setattr(* If the IDs do change before we take the ilock, we're covered * because the i_*dquot fields will get updated anyway. */ -if (XFS_IS_QUOTA_ON (mp)) { +if (ma->xattr_valid &&XFS_IS_QUOTA_ON (mp)) { error = xfs_qm_vop_dqalloc(ip, VFS_I(ip)->i_uid, - VFS_I(ip)->i_gid, fa->fsx_projid, + VFS_I(ip)->i_gid, ma->fsx_projid,
fs/xfs/xfs_ioctl.c xfs_ioctl_setattr( · line 1429
Quoted 10 lines
fs/xfs/xfs_ioctl.c +2
-2XFS_QMOPT_PQUOTA, NULL, NULL, &pdqp);if (error)return error; } -xfs_ioctl_setattr_prepare_dax (ip, fa); +xfs_ioctl_setattr_prepare_dax (ip, ma); - tp =xfs_ioctl_setattr_get_trans (file, pdqp); + tp =xfs_ioctl_setattr_get_trans (ip, pdqp);
(Heh, and now the ip -> file -> ip churn cycle is complete. :/)
Does this build on -rc4?
--D
Quoted 265 lines
fs/xfs/xfs_ioctl.c +11
-106if (IS_ERR (tp)) { error =PTR_ERR (tp); goto error_free_dquots; } -xfs_fill_fsxattr (ip, false, &old_fa); - error =vfs_ioc_fssetxattr_check (VFS_I (ip), &old_fa, fa); -if (error) - goto error_trans_cancel; - - error =xfs_ioctl_setattr_check_extsize (ip, fa); + error =xfs_ioctl_setattr_check_extsize (ip, ma);if (error) goto error_trans_cancel; - error =xfs_ioctl_setattr_check_cowextsize (ip, fa); + error =xfs_ioctl_setattr_check_cowextsize (ip, ma);if (error) goto error_trans_cancel; - error =xfs_ioctl_setattr_xflags (tp, ip, fa); + error =xfs_ioctl_setattr_xflags (tp, ip, ma);if (error) goto error_trans_cancel; +if (!ma->xattr_valid) + goto skip_xattr;/* * Change file ownership. Must be the owner or privileged. CAP_FSETID * overrides the following restrictions: @@ -1505,12 +1459,12 @@ xfs_ioctl_setattr(VFS_I (ip)->i_mode &= ~(S_ISUID |S_ISGID );/* Change the ownerships and register project quota modifications */ -if (ip->i_d.di_projid != fa->fsx_projid) { +if (ip->i_d.di_projid != ma->fsx_projid) {if (XFS_IS_QUOTA_RUNNING (mp) &&XFS_IS_PQUOTA_ON (mp)) { olddquot =xfs_qm_vop_chown (tp, ip, &ip->i_pdquot, pdqp); } - ip->i_d.di_projid = fa->fsx_projid; + ip->i_d.di_projid = ma->fsx_projid; }/* @@ -1519,16 +1473,17 @@ xfs_ioctl_setattr(* are set on the inode then unconditionally clear the extent size hint. */ if (ip->i_d.di_flags & (XFS_DIFLAG_EXTSIZE |XFS_DIFLAG_EXTSZINHERIT )) - ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog; + ip->i_d.di_extsize = ma->fsx_extsize >> mp->m_sb.sb_blocklog;else ip->i_d.di_extsize =0 ;if (xfs_sb_version_has_v3inode (&mp->m_sb) && (ip->i_d.di_flags2 &XFS_DIFLAG2_COWEXTSIZE )) - ip->i_d.di_cowextsize = fa->fsx_cowextsize >> + ip->i_d.di_cowextsize = ma->fsx_cowextsize >> mp->m_sb.sb_blocklog;else ip->i_d.di_cowextsize =0 ; +skip_xattr: error =xfs_trans_commit (tp);/* @@ -1546,91 +1501,6 @@ xfs_ioctl_setattr(return error; } -STATIC int -xfs_ioc_fssetxattr ( -struct file *filp, -void __user *arg) -{ -struct fsxattr fa; -int error; - -if (copy_from_user (&fa, arg,sizeof (fa))) -return -EFAULT ; - - error =mnt_want_write_file (filp); -if (error) -return error; - error =xfs_ioctl_setattr (filp, &fa); -mnt_drop_write_file (filp); -return error; -} - -STATIC int -xfs_ioc_getxflags ( -xfs_inode_t *ip, -void __user *arg) -{ -unsigned int flags; - - flags =xfs_di2lxflags (ip->i_d.di_flags, ip->i_d.di_flags2); -if (copy_to_user (arg, &flags,sizeof (flags))) -return -EFAULT ; -return 0 ; -} - -STATIC int -xfs_ioc_setxflags ( -struct xfs_inode *ip, -struct file *filp, -void __user *arg) -{ -struct xfs_trans *tp; -struct fsxattr fa; -struct fsxattr old_fa; -unsigned int flags; -int error; - -if (copy_from_user (&flags, arg,sizeof (flags))) -return -EFAULT ; - -if (flags & ~(FS_IMMUTABLE_FL |FS_APPEND_FL | \ -FS_NOATIME_FL |FS_NODUMP_FL | \ -FS_SYNC_FL |FS_DAX_FL )) -return -EOPNOTSUPP ; - - fa.fsx_xflags =xfs_merge_ioc_xflags (flags,xfs_ip2xflags (ip)); - - error =mnt_want_write_file (filp); -if (error) -return error; - -xfs_ioctl_setattr_prepare_dax (ip, &fa); - - tp =xfs_ioctl_setattr_get_trans (filp,NULL ); -if (IS_ERR (tp)) { - error =PTR_ERR (tp); - goto out_drop_write; - } - -xfs_fill_fsxattr (ip, false, &old_fa); - error =vfs_ioc_fssetxattr_check (VFS_I (ip), &old_fa, &fa); -if (error) { -xfs_trans_cancel (tp); - goto out_drop_write; - } - - error =xfs_ioctl_setattr_xflags (tp, ip, &fa); -if (error) { -xfs_trans_cancel (tp); - goto out_drop_write; - } - - error =xfs_trans_commit (tp); -out_drop_write: -mnt_drop_write_file (filp); -return error; -} - static bool xfs_getbmap_format( struct kgetbmap *p,@@ -2137,16 +2007,8 @@ xfs_file_ioctl(case XFS_IOC_GETVERSION :return put_user (inode->i_generation, (int __user *)arg); -case XFS_IOC_FSGETXATTR : -return xfs_ioc_fsgetxattr (ip,0 , arg);case XFS_IOC_FSGETXATTRA : -return xfs_ioc_fsgetxattr (ip,1 , arg); -case XFS_IOC_FSSETXATTR : -return xfs_ioc_fssetxattr (filp, arg); -case XFS_IOC_GETXFLAGS : -return xfs_ioc_getxflags (ip, arg); -case XFS_IOC_SETXFLAGS : -return xfs_ioc_setxflags (ip, filp, arg); +return xfs_ioc_fsgetxattra (ip, arg);case XFS_IOC_GETBMAP :case XFS_IOC_GETBMAPA :fs/xfs/xfs_ioctl.h +11
-0@@ -47,6 +47,17 @@ xfs_handle_to_dentry(void __user *uhandle, u32 hlen); +extern int +xfs_miscattr_get ( +struct dentry *dentry, +struct miscattr *ma); + +extern int +xfs_miscattr_set ( +struct user_namespace *mnt_userns, +struct dentry *dentry, +struct miscattr *ma); + extern long xfs_file_ioctl( struct file *filp,fs/xfs/xfs_ioctl32.c +0
-2@@ -484,8 +484,6 @@ xfs_file_compat_ioctl( }#endif /* long changes size, but xfs only copiese out 32 bits */ -case XFS_IOC_GETXFLAGS_32 : -case XFS_IOC_SETXFLAGS_32 :case XFS_IOC_GETVERSION_32 : cmd =_NATIVE_IOC (cmd, long);return xfs_file_ioctl (filp, cmd, p);fs/xfs/xfs_ioctl32.h +0
-2@@ -17,8 +17,6 @@*/ /* stock kernel-level ioctls we support */ -#define XFS_IOC_GETXFLAGS_32 FS_IOC32_GETFLAGS -#define XFS_IOC_SETXFLAGS_32 FS_IOC32_SETFLAGS#define XFS_IOC_GETVERSION_32 FS_IOC32_GETVERSION/* fs/xfs/xfs_iops.c +7
-0@@ -21,6 +21,7 @@#include "xfs_dir2.h" #include "xfs_iomap.h" #include "xfs_error.h" +#include "xfs_ioctl.h" #include <linux/posix_acl.h> #include <linux/security.h> @@ -1152,6 +1153,8 @@ static const struct inode_operations xfs_inode_operations = { .listxattr = xfs_vn_listxattr, .fiemap = xfs_vn_fiemap, .update_time = xfs_vn_update_time, + .miscattr_get = xfs_miscattr_get, + .miscattr_set = xfs_miscattr_set, };static const struct inode_operations xfs_dir_inode_operations = {@@ -1177,6 +1180,8 @@ static const struct inode_operations xfs_dir_inode_operations = { .listxattr = xfs_vn_listxattr, .update_time = xfs_vn_update_time, .tmpfile = xfs_vn_tmpfile, + .miscattr_get = xfs_miscattr_get, + .miscattr_set = xfs_miscattr_set, };static const struct inode_operations xfs_dir_ci_inode_operations = {@@ -1202,6 +1207,8 @@ static const struct inode_operations xfs_dir_ci_inode_operations = { .listxattr = xfs_vn_listxattr, .update_time = xfs_vn_update_time, .tmpfile = xfs_vn_tmpfile, + .miscattr_get = xfs_miscattr_get, + .miscattr_set = xfs_miscattr_set, };static const struct inode_operations xfs_symlink_inode_operations = {Signature · 1 line
2.30.2
PATCH v2 11/18 efivars: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/efivarfs/file.c | 77 --------------------------------------------- fs/efivarfs/inode.c | 44 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 77 deletions(-)
fs/efivarfs/file.c +0 -77
@@ -106,86 +106,9 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,return size; } -static inline unsigned int efivarfs_getflags (struct inode *inode) -{ -unsigned int i_flags; -unsigned int flags =0 ; - - i_flags = inode->i_flags; -if (i_flags &S_IMMUTABLE ) - flags |=FS_IMMUTABLE_FL ; -return flags; -} - -static int -efivarfs_ioc_getxflags (struct file *file,void __user *arg) -{ -struct inode *inode = file->f_mapping->host; -unsigned int flags =efivarfs_getflags (inode); - -if (copy_to_user (arg, &flags,sizeof (flags))) -return -EFAULT ; -return 0 ; -} - -static int -efivarfs_ioc_setxflags (struct file *file,void __user *arg) -{ -struct inode *inode = file->f_mapping->host; -unsigned int flags; -unsigned int i_flags =0 ; -unsigned int oldflags =efivarfs_getflags (inode); -int error; - -if (!inode_owner_or_capable (&init_user_ns, inode)) -return -EACCES ; - -if (copy_from_user (&flags, arg,sizeof (flags))) -return -EFAULT ; - -if (flags & ~FS_IMMUTABLE_FL ) -return -EOPNOTSUPP ; - -if (flags &FS_IMMUTABLE_FL ) - i_flags |=S_IMMUTABLE ; - - - error =mnt_want_write_file (file); -if (error) -return error; - -inode_lock (inode); - - error =vfs_ioc_setflags_prepare (inode, oldflags, flags); -if (error) - goto out; - -inode_set_flags (inode, i_flags,S_IMMUTABLE ); -out: -inode_unlock (inode); -mnt_drop_write_file (file); -return error; -} - -static long -efivarfs_file_ioctl (struct file *file,unsigned int cmd,unsigned long p) -{ -void __user *arg = (void __user *)p; - -switch (cmd) { -case FS_IOC_GETFLAGS : -return efivarfs_ioc_getxflags (file, arg); -case FS_IOC_SETFLAGS : -return efivarfs_ioc_setxflags (file, arg); - } - -return -ENOTTY ; -} -const struct file_operations efivarfs_file_operations = { .open = simple_open, .read = efivarfs_file_read, .write = efivarfs_file_write, .llseek = no_llseek, - .unlocked_ioctl = efivarfs_file_ioctl, };
fs/efivarfs/inode.c +44 -0
62 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v2 12/18 hfsplus: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/hfsplus/dir.c | 2 + fs/hfsplus/hfsplus_fs.h | 14 ++----- fs/hfsplus/inode.c | 54 ++++++++++++++++++++++++++ fs/hfsplus/ioctl.c | 84 ----------------------------------------- 4 files changed, 59 insertions(+), 95 deletions(-)
fs/hfsplus/dir.c +2 -0
@@ -569,6 +569,8 @@ const struct inode_operations hfsplus_dir_inode_operations = { .rename = hfsplus_rename, .getattr = hfsplus_getattr, .listxattr = hfsplus_listxattr, + .miscattr_get = hfsplus_miscattr_get, + .miscattr_set = hfsplus_miscattr_set, };const struct file_operations hfsplus_dir_operations = {
fs/hfsplus/hfsplus_fs.h +3 -11
@@ -344,17 +344,6 @@ static inline unsigned short hfsplus_min_io_size(struct super_block *sb)#define hfs_brec_goto hfsplus_brec_goto#define hfs_part_find hfsplus_part_find -/* -* definitions for ext2 flag ioctls (linux really needs a generic -* interface for this). -*/ - -/* ext2 ioctls (EXT2_IOC_GETFLAGS and EXT2_IOC_SETFLAGS) to support -* chattr/lsattr */ -#define HFSPLUS_IOC_EXT2_GETFLAGS FS_IOC_GETFLAGS -#define HFSPLUS_IOC_EXT2_SETFLAGS FS_IOC_SETFLAGS - -/* * hfs+-specific ioctl for making the filesystem bootable */
@@ -493,6 +482,9 @@ int hfsplus_getattr(struct user_namespace *mnt_userns, const struct path *path, unsigned int query_flags);int hfsplus_file_fsync (struct file *file,loff_t start,loff_t end,int datasync); +int hfsplus_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int hfsplus_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);/* ioctl.c */ long hfsplus_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);
fs/hfsplus/inode.c +54 -0
69 lines not on this page · raw message
fs/hfsplus/ioctl.c +0 -84
95 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v2 13/18 jfs: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/jfs/file.c | 6 +-- fs/jfs/ioctl.c | 105 ++++++++++++++------------------------------ fs/jfs/jfs_dinode.h | 7 --- fs/jfs/jfs_inode.h | 4 +- fs/jfs/namei.c | 6 +-- 5 files changed, 43 insertions(+), 85 deletions(-)
fs/jfs/file.c +3 -3
@@ -130,6 +130,8 @@ int jfs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,const struct inode_operations jfs_file_inode_operations = { .listxattr = jfs_listxattr, .setattr = jfs_setattr, + .miscattr_get = jfs_miscattr_get, + .miscattr_set = jfs_miscattr_set, #ifdef CONFIG_JFS_POSIX_ACL .get_acl = jfs_get_acl, .set_acl = jfs_set_acl,
@@ -147,7 +149,5 @@ const struct file_operations jfs_file_operations = { .fsync = jfs_fsync, .release = jfs_release, .unlocked_ioctl = jfs_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = jfs_compat_ioctl, -#endif + .compat_ioctl = compat_ptr_ioctl, };
fs/jfs/ioctl.c +34 -71
131 lines not on this page · raw message
fs/jfs/jfs_dinode.h +0 -7
@@ -160,11 +160,4 @@ struct dinode {#define JFS_FL_USER_MODIFIABLE 0x03F80000#define JFS_FL_INHERIT 0x03C80000 -/* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */ -#define JFS_IOC_GETFLAGS _IOR('f', 1, long) -#define JFS_IOC_SETFLAGS _IOW('f', 2, long) - -#define JFS_IOC_GETFLAGS32 _IOR('f', 1, int) -#define JFS_IOC_SETFLAGS32 _IOW('f', 2, int) -#endif /*_H_JFS_DINODE */
fs/jfs/jfs_inode.h +3 -1
@@ -9,8 +9,10 @@ struct fid;extern struct inode *ialloc (struct inode *,umode_t );extern int jfs_fsync (struct file *,loff_t ,loff_t ,int ); +extern int jfs_miscattr_get (struct dentry *dentry,struct miscattr *ma); +extern int jfs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);extern long jfs_ioctl (struct file *,unsigned int ,unsigned long ); -extern long jfs_compat_ioctl (struct file *,unsigned int ,unsigned long );extern struct inode *jfs_iget (struct super_block *,unsigned long );extern int jfs_commit_inode (struct inode *,int );extern int jfs_write_inode (struct inode *,struct writeback_control *);
fs/jfs/namei.c +3 -3
@@ -1522,6 +1522,8 @@ const struct inode_operations jfs_dir_inode_operations = { .rename = jfs_rename, .listxattr = jfs_listxattr, .setattr = jfs_setattr, + .miscattr_get = jfs_miscattr_get, + .miscattr_set = jfs_miscattr_set, #ifdef CONFIG_JFS_POSIX_ACL .get_acl = jfs_get_acl, .set_acl = jfs_set_acl,
@@ -1533,9 +1535,7 @@ const struct file_operations jfs_dir_operations = { .iterate = jfs_readdir, .fsync = jfs_fsync, .unlocked_ioctl = jfs_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = jfs_compat_ioctl, -#endif + .compat_ioctl = compat_ptr_ioctl, .llseek = generic_file_llseek, };
Signature · 1 line
2.30.2
PATCH v2 14/18 nilfs2: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/nilfs2/file.c | 2 ++ fs/nilfs2/ioctl.c | 61 ++++++++++++++--------------------------------- fs/nilfs2/namei.c | 2 ++ fs/nilfs2/nilfs.h | 3 +++ 4 files changed, 25 insertions(+), 43 deletions(-)
fs/nilfs2/file.c +2 -0
@@ -148,6 +148,8 @@ const struct inode_operations nilfs_file_inode_operations = { .setattr = nilfs_setattr, .permission = nilfs_permission, .fiemap = nilfs_fiemap, + .miscattr_get = nilfs_miscattr_get, + .miscattr_set = nilfs_miscattr_set, };/* end of file */
fs/nilfs2/ioctl.c +18 -43
108 lines not on this page · raw message
fs/nilfs2/namei.c +2 -0
@@ -552,6 +552,8 @@ const struct inode_operations nilfs_dir_inode_operations = { .setattr = nilfs_setattr, .permission = nilfs_permission, .fiemap = nilfs_fiemap, + .miscattr_get = nilfs_miscattr_get, + .miscattr_set = nilfs_miscattr_set, };const struct inode_operations nilfs_special_inode_operations = {
fs/nilfs2/nilfs.h +3 -0
@@ -243,6 +243,9 @@ extern void nilfs_set_link(struct inode *, struct nilfs_dir_entry *,extern int nilfs_sync_file (struct file *,loff_t ,loff_t ,int );/* ioctl.c */ +int nilfs_miscattr_get (struct dentry *dentry,struct miscattr *m); +int nilfs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);long nilfs_ioctl (struct file *,unsigned int ,unsigned long );long nilfs_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg); int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *,
Signature · 1 line
2.30.2
PATCH v2 15/18 ocfs2: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/ocfs2/file.c | 2 ++ fs/ocfs2/ioctl.c | 59 ++++++++++++++---------------------------- fs/ocfs2/ioctl.h | 3 +++ fs/ocfs2/namei.c | 3 +++ fs/ocfs2/ocfs2_ioctl.h | 8 ------ 5 files changed, 27 insertions(+), 48 deletions(-)
fs/ocfs2/file.c +2 -0
@@ -2645,6 +2645,8 @@ const struct inode_operations ocfs2_file_iops = { .fiemap = ocfs2_fiemap, .get_acl = ocfs2_iop_get_acl, .set_acl = ocfs2_iop_set_acl, + .miscattr_get = ocfs2_miscattr_get, + .miscattr_set = ocfs2_miscattr_set, };const struct inode_operations ocfs2_special_file_iops = {
fs/ocfs2/ioctl.c +19 -40
125 lines not on this page · raw message
fs/ocfs2/ioctl.h +3 -0
@@ -11,6 +11,9 @@#ifndef OCFS2_IOCTL_PROTO_H #define OCFS2_IOCTL_PROTO_H +int ocfs2_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int ocfs2_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);long ocfs2_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);long ocfs2_compat_ioctl (struct file *file,unsigned cmd,unsigned long arg);
fs/ocfs2/namei.c +3 -0
@@ -50,6 +50,7 @@#include "xattr.h" #include "acl.h" #include "ocfs2_trace.h" +#include "ioctl.h" #include "buffer_head_io.h"
@@ -2918,4 +2919,6 @@ const struct inode_operations ocfs2_dir_iops = { .fiemap = ocfs2_fiemap, .get_acl = ocfs2_iop_get_acl, .set_acl = ocfs2_iop_set_acl, + .miscattr_get = ocfs2_miscattr_get, + .miscattr_set = ocfs2_miscattr_set, };
fs/ocfs2/ocfs2_ioctl.h +0 -8
@@ -12,14 +12,6 @@#ifndef OCFS2_IOCTL_H #define OCFS2_IOCTL_H -/* -* ioctl commands -*/ -#define OCFS2_IOC_GETFLAGS FS_IOC_GETFLAGS -#define OCFS2_IOC_SETFLAGS FS_IOC_SETFLAGS -#define OCFS2_IOC32_GETFLAGS FS_IOC32_GETFLAGS -#define OCFS2_IOC32_SETFLAGS FS_IOC32_SETFLAGS -/* * Space reservation / allocation / free ioctls and argument structure * are designed to be compatible with XFS.
Signature · 1 line
2.30.2
PATCH v2 16/18 reiserfs: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/reiserfs/file.c | 2 + fs/reiserfs/ioctl.c | 121 +++++++++++++++++++---------------------- fs/reiserfs/namei.c | 2 + fs/reiserfs/reiserfs.h | 7 ++- fs/reiserfs/super.c | 2 +- 5 files changed, 64 insertions(+), 70 deletions(-)
fs/reiserfs/file.c +2 -0
@@ -258,4 +258,6 @@ const struct inode_operations reiserfs_file_inode_operations = { .permission = reiserfs_permission, .get_acl = reiserfs_get_acl, .set_acl = reiserfs_set_acl, + .miscattr_get = reiserfs_miscattr_get, + .miscattr_set = reiserfs_miscattr_set, };
fs/reiserfs/ioctl.c +55 -66
157 lines not on this page · raw message
fs/reiserfs/namei.c +2 -0
@@ -1660,6 +1660,8 @@ const struct inode_operations reiserfs_dir_inode_operations = { .permission = reiserfs_permission, .get_acl = reiserfs_get_acl, .set_acl = reiserfs_set_acl, + .miscattr_get = reiserfs_miscattr_get, + .miscattr_set = reiserfs_miscattr_set, };/*
fs/reiserfs/reiserfs.h +4 -3
@@ -18,8 +18,6 @@/* the 32 bit compat definitions with int argument */ #define REISERFS_IOC32_UNPACK _IOW(0xCD, 1, int) -#define REISERFS_IOC32_GETFLAGS FS_IOC32_GETFLAGS -#define REISERFS_IOC32_SETFLAGS FS_IOC32_SETFLAGS#define REISERFS_IOC32_GETVERSION FS_IOC32_GETVERSION#define REISERFS_IOC32_SETVERSION FS_IOC32_SETVERSION
@@ -3408,7 +3406,10 @@ __u32 r5_hash(const signed char *msg, int len);#define SPARE_SPACE 500/* prototypes from ioctl.c */ +int reiserfs_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int reiserfs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);long reiserfs_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);long reiserfs_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg); -int reiserfs_unpack (struct inode *inode,struct file *filp); +int reiserfs_unpack (struct inode *inode);
fs/reiserfs/super.c +1 -1
@@ -2408,7 +2408,7 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,* IO to work */ if (!(REISERFS_I (inode)->i_flags & i_nopack_mask)) { - err =reiserfs_unpack (inode,NULL ); + err =reiserfs_unpack (inode);if (err) {reiserfs_warning (sb,"super-6520" , "Unpacking tail of quota file failed"
Signature · 1 line
2.30.2
PATCH v2 17/18 ubifs: convert to miscattr
In reply to Miklos SzerediUse the miscattr API to let the VFS handle locking, permission checking and conversion.
--- fs/ubifs/dir.c | 2 ++ fs/ubifs/file.c | 2 ++ fs/ubifs/ioctl.c | 74 ++++++++++++++++++++---------------------------- fs/ubifs/ubifs.h | 3 ++ 4 files changed, 38 insertions(+), 43 deletions(-)
fs/ubifs/dir.c +2 -0
@@ -1637,6 +1637,8 @@ const struct inode_operations ubifs_dir_inode_operations = { .listxattr = ubifs_listxattr, .update_time = ubifs_update_time, .tmpfile = ubifs_tmpfile, + .miscattr_get = ubifs_miscattr_get, + .miscattr_set = ubifs_miscattr_set, };const struct file_operations ubifs_dir_operations = {
fs/ubifs/file.c +2 -0
@@ -1648,6 +1648,8 @@ const struct inode_operations ubifs_file_inode_operations = { .getattr = ubifs_getattr, .listxattr = ubifs_listxattr, .update_time = ubifs_update_time, + .miscattr_get = ubifs_miscattr_get, + .miscattr_set = ubifs_miscattr_set, };const struct inode_operations ubifs_symlink_inode_operations = {
fs/ubifs/ioctl.c +31 -43
109 lines not on this page · raw message
fs/ubifs/ubifs.h +3 -0
@@ -2053,6 +2053,9 @@ int ubifs_recover_size(struct ubifs_info *c, bool in_place);void ubifs_destroy_size_tree (struct ubifs_info *c);/* ioctl.c */ +int ubifs_miscattr_get (struct dentry *dentry,struct miscattr *ma); +int ubifs_miscattr_set (struct user_namespace *mnt_userns, +struct dentry *dentry,struct miscattr *ma);long ubifs_ioctl (struct file *file,unsigned int cmd,unsigned long arg);void ubifs_set_inode_flags (struct inode *inode);#ifdef CONFIG_COMPAT
Signature · 1 line
2.30.2
PATCH v2 18/18 vfs: remove unused ioctl helpers
In reply to Miklos SzerediRemove vfs_ioc_setflags_prepare(), vfs_ioc_fssetxattr_check() and simple_fill_fsxattr(), which are no longer used.
--- fs/inode.c | 87 ---------------------------------------------- include/linux/fs.h | 12 ------- 2 files changed, 99 deletions(-)
fs/inode.c +0 -87
@@ -12,7 +12,6 @@#include <linux/security.h> #include <linux/cdev.h> #include <linux/memblock.h> -#include <linux/fscrypt.h> #include <linux/fsnotify.h> #include <linux/mount.h> #include <linux/posix_acl.h>
@@ -2314,89 +2313,3 @@ struct timespec64 current_time(struct inode *inode)return timestamp_truncate (now, inode); }EXPORT_SYMBOL (current_time); - -/* -* Generic function to check FS_IOC_SETFLAGS values and reject any invalid -* configurations. -* -* Note: the caller should be holding i_mutex, or else be sure that they have -* exclusive access to the inode structure. -*/ -int vfs_ioc_setflags_prepare (struct inode *inode,unsigned int oldflags, -unsigned int flags) -{ -/* -* The IMMUTABLE and APPEND_ONLY flags can only be changed by -* the relevant capability. -* -* This test looks nicer. Thanks to Pauline Middelink -*/ -if ((flags ^ oldflags) & (FS_APPEND_FL |FS_IMMUTABLE_FL ) && - !capable (CAP_LINUX_IMMUTABLE )) -return -EPERM ; - -return fscrypt_prepare_setflags (inode, oldflags, flags); -} -EXPORT_SYMBOL (vfs_ioc_setflags_prepare); - -/* -* Generic function to check FS_IOC_FSSETXATTR values and reject any invalid -* configurations. -* -* Note: the caller should be holding i_mutex, or else be sure that they have -* exclusive access to the inode structure. -*/ -int vfs_ioc_fssetxattr_check (struct inode *inode,const struct fsxattr *old_fa, -struct fsxattr *fa) -{ -/* -* Can't modify an immutable/append-only file unless we have -* appropriate permission. -*/ -if ((old_fa->fsx_xflags ^ fa->fsx_xflags) & - (FS_XFLAG_IMMUTABLE |FS_XFLAG_APPEND ) && - !capable (CAP_LINUX_IMMUTABLE )) -return -EPERM ; - -/* -* Project Quota ID state is only allowed to change from within the init -* namespace. Enforce that restriction only if we are trying to change -* the quota ID state. Everything else is allowed in user namespaces. -*/ -if (current_user_ns () != &init_user_ns) { -if (old_fa->fsx_projid != fa->fsx_projid) -return -EINVAL ; -if ((old_fa->fsx_xflags ^ fa->fsx_xflags) & -FS_XFLAG_PROJINHERIT ) -return -EINVAL ; - } - -/* Check extent size hints. */ -if ((fa->fsx_xflags &FS_XFLAG_EXTSIZE ) && !S_ISREG (inode->i_mode)) -return -EINVAL ; - -if ((fa->fsx_xflags &FS_XFLAG_EXTSZINHERIT ) && - !S_ISDIR (inode->i_mode)) -return -EINVAL ; - -if ((fa->fsx_xflags &FS_XFLAG_COWEXTSIZE ) && - !S_ISREG (inode->i_mode) && !S_ISDIR (inode->i_mode)) -return -EINVAL ; - -/* -* It is only valid to set the DAX flag on regular files and -* directories on filesystems. -*/ -if ((fa->fsx_xflags &FS_XFLAG_DAX ) && - !(S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode))) -return -EINVAL ; - -/* Extent size hints of zero turn off the flags. */ -if (fa->fsx_extsize ==0 ) - fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE |FS_XFLAG_EXTSZINHERIT ); -if (fa->fsx_cowextsize ==0 ) - fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE ; - -return 0 ; -} -EXPORT_SYMBOL (vfs_ioc_fssetxattr_check);
include/linux/fs.h +0 -12
@@ -3571,18 +3571,6 @@ extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,extern int generic_fadvise (struct file *file,loff_t offset,loff_t len,int advice); -int vfs_ioc_setflags_prepare (struct inode *inode,unsigned int oldflags, -unsigned int flags); - -int vfs_ioc_fssetxattr_check (struct inode *inode,const struct fsxattr *old_fa, -struct fsxattr *fa); - -static inline void simple_fill_fsxattr (struct fsxattr *fa,__u32 xflags) -{ -memset (fa,0 ,sizeof (*fa)); - fa->fsx_xflags = xflags; -} -/* * Flush file data before changing attributes. Caller must hold any locks * required to prevent further writes to this file until we're done setting
Signature · 1 line
2.30.2
Re: [PATCH v2 18/18] vfs: remove unused ioctl helpers
Quoted 4 lines · Miklos Szeredi
Remove
vfs_ioc_setflags_prepare(),vfs_ioc_fssetxattr_check()andsimple_fill_fsxattr(), which are no longer used.Signed-off-by Miklos Szeredi <[email protected]>
Woo hoo, so much boilerplate goes away!
--D
Quoted 133 lines
--- fs/inode.c | 87 ---------------------------------------------- include/linux/fs.h | 12 ------- 2 files changed, 99 deletions(-)fs/inode.c +0
-87@@ -12,7 +12,6 @@#include <linux/security.h> #include <linux/cdev.h> #include <linux/memblock.h> -#include <linux/fscrypt.h> #include <linux/fsnotify.h> #include <linux/mount.h> #include <linux/posix_acl.h> @@ -2314,89 +2313,3 @@ struct timespec64 current_time(struct inode *inode)return timestamp_truncate (now, inode); }EXPORT_SYMBOL (current_time); - -/* -* Generic function to check FS_IOC_SETFLAGS values and reject any invalid -* configurations. -* -* Note: the caller should be holding i_mutex, or else be sure that they have -* exclusive access to the inode structure. -*/ -int vfs_ioc_setflags_prepare (struct inode *inode,unsigned int oldflags, -unsigned int flags) -{ -/* -* The IMMUTABLE and APPEND_ONLY flags can only be changed by -* the relevant capability. -* -* This test looks nicer. Thanks to Pauline Middelink -*/ -if ((flags ^ oldflags) & (FS_APPEND_FL |FS_IMMUTABLE_FL ) && - !capable (CAP_LINUX_IMMUTABLE )) -return -EPERM ; - -return fscrypt_prepare_setflags (inode, oldflags, flags); -} -EXPORT_SYMBOL (vfs_ioc_setflags_prepare); - -/* -* Generic function to check FS_IOC_FSSETXATTR values and reject any invalid -* configurations. -* -* Note: the caller should be holding i_mutex, or else be sure that they have -* exclusive access to the inode structure. -*/ -int vfs_ioc_fssetxattr_check (struct inode *inode,const struct fsxattr *old_fa, -struct fsxattr *fa) -{ -/* -* Can't modify an immutable/append-only file unless we have -* appropriate permission. -*/ -if ((old_fa->fsx_xflags ^ fa->fsx_xflags) & - (FS_XFLAG_IMMUTABLE |FS_XFLAG_APPEND ) && - !capable (CAP_LINUX_IMMUTABLE )) -return -EPERM ; - -/* -* Project Quota ID state is only allowed to change from within the init -* namespace. Enforce that restriction only if we are trying to change -* the quota ID state. Everything else is allowed in user namespaces. -*/ -if (current_user_ns () != &init_user_ns) { -if (old_fa->fsx_projid != fa->fsx_projid) -return -EINVAL ; -if ((old_fa->fsx_xflags ^ fa->fsx_xflags) & -FS_XFLAG_PROJINHERIT ) -return -EINVAL ; - } - -/* Check extent size hints. */ -if ((fa->fsx_xflags &FS_XFLAG_EXTSIZE ) && !S_ISREG (inode->i_mode)) -return -EINVAL ; - -if ((fa->fsx_xflags &FS_XFLAG_EXTSZINHERIT ) && - !S_ISDIR (inode->i_mode)) -return -EINVAL ; - -if ((fa->fsx_xflags &FS_XFLAG_COWEXTSIZE ) && - !S_ISREG (inode->i_mode) && !S_ISDIR (inode->i_mode)) -return -EINVAL ; - -/* -* It is only valid to set the DAX flag on regular files and -* directories on filesystems. -*/ -if ((fa->fsx_xflags &FS_XFLAG_DAX ) && - !(S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode))) -return -EINVAL ; - -/* Extent size hints of zero turn off the flags. */ -if (fa->fsx_extsize ==0 ) - fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE |FS_XFLAG_EXTSZINHERIT ); -if (fa->fsx_cowextsize ==0 ) - fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE ; - -return 0 ; -} -EXPORT_SYMBOL (vfs_ioc_fssetxattr_check);include/linux/fs.h +0
-12@@ -3571,18 +3571,6 @@ extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,extern int generic_fadvise (struct file *file,loff_t offset,loff_t len,int advice); -int vfs_ioc_setflags_prepare (struct inode *inode,unsigned int oldflags, -unsigned int flags); - -int vfs_ioc_fssetxattr_check (struct inode *inode,const struct fsxattr *old_fa, -struct fsxattr *fa); - -static inline void simple_fill_fsxattr (struct fsxattr *fa,__u32 xflags) -{ -memset (fa,0 ,sizeof (*fa)); - fa->fsx_xflags = xflags; -} -/* * Flush file data before changing attributes. Caller must hold any locks * required to prevent further writes to this file until we're done setting Signature · 1 line
2.30.2