Skip to content

Commit da6fcc6

Browse files
author
Miklos Szeredi
committed
fuse: fuse_dev_ioctl_clone() should wait for device file to be initialized
Use fuse_get_dev() not __fuse_get_dev() on the old fd, since in the case of synchronous INIT the caller will want to wait for the device file to be available for cloning, just like I/O wants to wait instead of returning an error. Fixes: dfb84c3 ("fuse: allow synchronous FUSE_INIT") Cc: stable@vger.kernel.org # v6.18 Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent aff1204 commit da6fcc6

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

fs/fuse/dev.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,9 +2597,8 @@ static int fuse_device_clone(struct fuse_conn *fc, struct file *new)
25972597

25982598
static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp)
25992599
{
2600-
int res;
26012600
int oldfd;
2602-
struct fuse_dev *fud = NULL;
2601+
struct fuse_dev *fud;
26032602

26042603
if (get_user(oldfd, argp))
26052604
return -EFAULT;
@@ -2612,17 +2611,15 @@ static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp)
26122611
* Check against file->f_op because CUSE
26132612
* uses the same ioctl handler.
26142613
*/
2615-
if (fd_file(f)->f_op == file->f_op)
2616-
fud = __fuse_get_dev(fd_file(f));
2614+
if (fd_file(f)->f_op != file->f_op)
2615+
return -EINVAL;
26172616

2618-
res = -EINVAL;
2619-
if (fud) {
2620-
mutex_lock(&fuse_mutex);
2621-
res = fuse_device_clone(fud->fc, file);
2622-
mutex_unlock(&fuse_mutex);
2623-
}
2617+
fud = fuse_get_dev(fd_file(f));
2618+
if (IS_ERR(fud))
2619+
return PTR_ERR(fud);
26242620

2625-
return res;
2621+
guard(mutex)(&fuse_mutex);
2622+
return fuse_device_clone(fud->fc, file);
26262623
}
26272624

26282625
static long fuse_dev_ioctl_backing_open(struct file *file,

0 commit comments

Comments
 (0)