fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN
Subsystems (3)
PATCH 1/1 fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN
Only f_path is used from backing files registered with FUSE_DEV_IOC_BACKING_OPEN, so it makes sense to allow O_PATH descriptors.
O_PATH files have an empty f_op, so don't check read_iter/write_iter.
--- fs/fuse/passthrough.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
fs/fuse/passthrough.c +1 -5
@@ -228,15 +228,11 @@ int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map)if (map->flags || map->padding) goto out; - file =fget (map->fd); + file =fget_raw (map->fd); res = -EBADF ;if (!file) goto out; - res = -EOPNOTSUPP ; -if (!file->f_op->read_iter || !file->f_op->write_iter) - goto out_fput; - backing_sb =file_inode (file)->i_sb; res = -ELOOP ;if (backing_sb->s_stack_depth >= fc->max_stack_depth)
Signature · 1 line
2.46.0
Quoted 7 lines · Miklos Szeredi
Only
f_pathis used from backing files registered withFUSE_DEV_IOC_BACKING_OPEN, so it makes sense to allowO_PATHdescriptors.
O_PATHfiles have an emptyf_op, so don't check read_iter/write_iter.Signed-off-by Miklos Szeredi <[email protected]>
Agreed.
Quoted 12 lines
--- fs/fuse/passthrough.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)fs/fuse/passthrough.c +0
-0@@ -228,15 +228,11 @@ int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map)if (map->flags || map->padding) goto out;
fs/fuse/passthrough.c int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map) · line 239
Quoted 10 lines
fs/fuse/passthrough.c +1
-5- file =fget (map->fd); + file =fget_raw (map->fd); res = -EBADF ;if (!file) goto out; - res = -EOPNOTSUPP ; -if (!file->f_op->read_iter || !file->f_op->write_iter) - goto out_fput; -
FWIW, I have made those sanity checks opt-in in my fuse-backing-inode-wip branch:
https://github.com/amir73il/linux/commit/24c9a87bb11d76414b85960c0e3638a655a9c9a1
But that could be added later.
Thanks,
Amir.
Miklos Szeredi
maintainerQuoted 8 lines · Amir Goldstein
fs/fuse/passthrough.c int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map) · line 239
Quoted 4 lines · Miklos Szeredi
fs/fuse/passthrough.c +0
-4- res = -EOPNOTSUPP ; -if (!file->f_op->read_iter || !file->f_op->write_iter) - goto out_fput; -
Quoted 5 lines
FWIW, I have made those sanity checks opt-in in my fuse-backing-inode-wip branch:
https://github.com/amir73il/linux/commit/24c9a87bb11d76414b85960c0e3638a655a9c9a1But that could be added later.
This is the wrong place to check the f_op.
We could do it in backing_file_open(), but this isn't going to be a common error, so I guess just returning an error at read/write time is also okay.
Thanks,
Miklos
Amir Goldstein
maintainerQuoted 14 lines · Miklos Szeredi
Quoted 12 lines · Amir Goldstein
fs/fuse/passthrough.c int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map) · line 239
Quoted 4 lines · Miklos Szeredi
fs/fuse/passthrough.c +0
-4- res = -EOPNOTSUPP ; -if (!file->f_op->read_iter || !file->f_op->write_iter) - goto out_fput; -FWIW, I have made those sanity checks opt-in in my fuse-backing-inode-wip branch:
https://github.com/amir73il/linux/commit/24c9a87bb11d76414b85960c0e3638a655a9c9a1
Quoted 8 lines
Quoted 1 line
But that could be added later.
This is the wrong place to check the
f_op.We could do it in
backing_file_open(), but this isn't going to be a common error, so I guess just returning an error at read/write time is also okay.
Yeh. works for me.
Thanks,
Amir.