fuse: add inode/permission checks to fileattr_get/fileattr_set
authorAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Thu, 26 Jan 2023 10:23:18 +0000 (11:23 +0100)
committerMiklos Szeredi <mszeredi@redhat.com>
Thu, 26 Jan 2023 16:22:04 +0000 (17:22 +0100)
It looks like these checks were accidentally lost during the conversion to
fileattr API.

Fixes: 72227eac177d ("fuse: convert to fileattr")
Cc: <stable@vger.kernel.org> # v5.13
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/ioctl.c

index fcce94a..8ba1545 100644 (file)
@@ -419,6 +419,12 @@ static struct fuse_file *fuse_priv_ioctl_prepare(struct inode *inode)
        struct fuse_mount *fm = get_fuse_mount(inode);
        bool isdir = S_ISDIR(inode->i_mode);
 
+       if (!fuse_allow_current_process(fm->fc))
+               return ERR_PTR(-EACCES);
+
+       if (fuse_is_bad(inode))
+               return ERR_PTR(-EIO);
+
        if (!S_ISREG(inode->i_mode) && !isdir)
                return ERR_PTR(-ENOTTY);