ovl: remove unneeded ioctls
authorMiklos Szeredi <mszeredi@redhat.com>
Thu, 8 Apr 2021 09:11:19 +0000 (11:11 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Mon, 12 Apr 2021 13:04:30 +0000 (15:04 +0200)
The FS_IOC_[GS]ETFLAGS/FS_IOC_FS[GS]ETXATTR ioctls are now handled via the
fileattr api.  The only unconverted filesystem remaining is CIFS and it is
not allowed to be overlayed due to case insensitive filenames.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/file.c
fs/overlayfs/overlayfs.h
fs/overlayfs/readdir.c

index dbfb35f..9bd4167 100644 (file)
@@ -491,112 +491,6 @@ static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
        return ret;
 }
 
-static long ovl_real_ioctl(struct file *file, unsigned int cmd,
-                          unsigned long arg)
-{
-       struct fd real;
-       long ret;
-
-       ret = ovl_real_fdget(file, &real);
-       if (ret)
-               return ret;
-
-       ret = security_file_ioctl(real.file, cmd, arg);
-       if (!ret) {
-               /*
-                * Don't override creds, since we currently can't safely check
-                * permissions before doing so.
-                */
-               ret = vfs_ioctl(real.file, cmd, arg);
-       }
-
-       fdput(real);
-
-       return ret;
-}
-
-static long ovl_ioctl_set_flags(struct file *file, unsigned int cmd,
-                               unsigned long arg)
-{
-       long ret;
-       struct inode *inode = file_inode(file);
-
-       if (!inode_owner_or_capable(&init_user_ns, inode))
-               return -EACCES;
-
-       ret = mnt_want_write_file(file);
-       if (ret)
-               return ret;
-
-       inode_lock(inode);
-
-       /*
-        * 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;
-
-       ret = ovl_real_ioctl(file, cmd, arg);
-
-       ovl_copyflags(ovl_inode_real(inode), inode);
-unlock:
-       inode_unlock(inode);
-
-       mnt_drop_write_file(file);
-
-       return ret;
-
-}
-
-long ovl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-       long ret;
-
-       switch (cmd) {
-       case FS_IOC_GETFLAGS:
-       case FS_IOC_FSGETXATTR:
-               ret = ovl_real_ioctl(file, cmd, arg);
-               break;
-
-       case FS_IOC_FSSETXATTR:
-       case FS_IOC_SETFLAGS:
-               ret = ovl_ioctl_set_flags(file, cmd, arg);
-               break;
-
-       default:
-               ret = -ENOTTY;
-       }
-
-       return ret;
-}
-
-#ifdef CONFIG_COMPAT
-long ovl_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-       switch (cmd) {
-       case FS_IOC32_GETFLAGS:
-               cmd = FS_IOC_GETFLAGS;
-               break;
-
-       case FS_IOC32_SETFLAGS:
-               cmd = FS_IOC_SETFLAGS;
-               break;
-
-       default:
-               return -ENOIOCTLCMD;
-       }
-
-       return ovl_ioctl(file, cmd, arg);
-}
-#endif
-
 enum ovl_copyop {
        OVL_COPY,
        OVL_CLONE,
@@ -696,10 +590,6 @@ const struct file_operations ovl_file_operations = {
        .mmap           = ovl_mmap,
        .fallocate      = ovl_fallocate,
        .fadvise        = ovl_fadvise,
-       .unlocked_ioctl = ovl_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl   = ovl_compat_ioctl,
-#endif
        .splice_read    = generic_file_splice_read,
        .splice_write   = iter_file_splice_write,
 
index a1c1b5a..f38cb5e 100644 (file)
@@ -519,8 +519,6 @@ struct dentry *ovl_create_temp(struct dentry *workdir, struct ovl_cattr *attr);
 extern const struct file_operations ovl_file_operations;
 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_fileattr_get(struct dentry *dentry, struct fileattr *fa);
 int ovl_fileattr_set(struct user_namespace *mnt_userns,
                     struct dentry *dentry, struct fileattr *fa);
index f404a78..1ddad09 100644 (file)
@@ -963,10 +963,6 @@ const struct file_operations ovl_dir_operations = {
        .llseek         = ovl_dir_llseek,
        .fsync          = ovl_dir_fsync,
        .release        = ovl_dir_release,
-       .unlocked_ioctl = ovl_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl   = ovl_compat_ioctl,
-#endif
 };
 
 int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)