Skip to content

Commit 1df2731

Browse files
committed
Merge tag 'fuse-fixes-5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse fixes from Miklos Szeredi: "Fix a deadlock and a couple of other bugs" * tag 'fuse-fixes-5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: fuse: 32-bit user space ioctl compat for fuse device virtiofs: Fail dax mount if device does not support it fuse: fix live lock in fuse_iget()
2 parents 4108e10 + f8425c9 commit 1df2731

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

fs/fuse/dev.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,19 +2229,21 @@ static int fuse_device_clone(struct fuse_conn *fc, struct file *new)
22292229
static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
22302230
unsigned long arg)
22312231
{
2232-
int err = -ENOTTY;
2232+
int res;
2233+
int oldfd;
2234+
struct fuse_dev *fud = NULL;
22332235

2234-
if (cmd == FUSE_DEV_IOC_CLONE) {
2235-
int oldfd;
2236+
if (_IOC_TYPE(cmd) != FUSE_DEV_IOC_MAGIC)
2237+
return -ENOTTY;
22362238

2237-
err = -EFAULT;
2238-
if (!get_user(oldfd, (__u32 __user *) arg)) {
2239+
switch (_IOC_NR(cmd)) {
2240+
case _IOC_NR(FUSE_DEV_IOC_CLONE):
2241+
res = -EFAULT;
2242+
if (!get_user(oldfd, (__u32 __user *)arg)) {
22392243
struct file *old = fget(oldfd);
22402244

2241-
err = -EINVAL;
2245+
res = -EINVAL;
22422246
if (old) {
2243-
struct fuse_dev *fud = NULL;
2244-
22452247
/*
22462248
* Check against file->f_op because CUSE
22472249
* uses the same ioctl handler.
@@ -2252,14 +2254,18 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
22522254

22532255
if (fud) {
22542256
mutex_lock(&fuse_mutex);
2255-
err = fuse_device_clone(fud->fc, file);
2257+
res = fuse_device_clone(fud->fc, file);
22562258
mutex_unlock(&fuse_mutex);
22572259
}
22582260
fput(old);
22592261
}
22602262
}
2263+
break;
2264+
default:
2265+
res = -ENOTTY;
2266+
break;
22612267
}
2262-
return err;
2268+
return res;
22632269
}
22642270

22652271
const struct file_operations fuse_dev_operations = {

fs/fuse/fuse_i.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ static inline u64 fuse_get_attr_version(struct fuse_conn *fc)
863863

864864
static inline void fuse_make_bad(struct inode *inode)
865865
{
866+
remove_inode_hash(inode);
866867
set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state);
867868
}
868869

fs/fuse/virtio_fs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,15 @@ static int virtio_fs_fill_super(struct super_block *sb, struct fs_context *fsc)
13241324

13251325
/* virtiofs allocates and installs its own fuse devices */
13261326
ctx->fudptr = NULL;
1327-
if (ctx->dax)
1327+
if (ctx->dax) {
1328+
if (!fs->dax_dev) {
1329+
err = -EINVAL;
1330+
pr_err("virtio-fs: dax can't be enabled as filesystem"
1331+
" device does not support it.\n");
1332+
goto err_free_fuse_devs;
1333+
}
13281334
ctx->dax_dev = fs->dax_dev;
1335+
}
13291336
err = fuse_fill_super_common(sb, ctx);
13301337
if (err < 0)
13311338
goto err_free_fuse_devs;

include/uapi/linux/fuse.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ struct fuse_notify_retrieve_in {
903903
};
904904

905905
/* Device ioctls: */
906-
#define FUSE_DEV_IOC_CLONE _IOR(229, 0, uint32_t)
906+
#define FUSE_DEV_IOC_MAGIC 229
907+
#define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
907908

908909
struct fuse_lseek_in {
909910
uint64_t fh;

0 commit comments

Comments
 (0)