linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN
@ 2024-09-13 10:47 Miklos Szeredi
  2024-09-13 11:04 ` Amir Goldstein
  0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2024-09-13 10:47 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Amir Goldstein

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.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 fs/fuse/passthrough.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c
index 9666d13884ce..ba3207f6c4ce 100644
--- a/fs/fuse/passthrough.c
+++ b/fs/fuse/passthrough.c
@@ -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)
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN
  2024-09-13 10:47 [PATCH] fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN Miklos Szeredi
@ 2024-09-13 11:04 ` Amir Goldstein
  2024-09-13 11:12   ` Miklos Szeredi
  0 siblings, 1 reply; 4+ messages in thread
From: Amir Goldstein @ 2024-09-13 11:04 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-fsdevel

On Fri, Sep 13, 2024 at 12:50 PM Miklos Szeredi <mszeredi@redhat.com> wrote:
>
> 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.
>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>

Agreed.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

> ---
>  fs/fuse/passthrough.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c
> index 9666d13884ce..ba3207f6c4ce 100644
> --- a/fs/fuse/passthrough.c
> +++ b/fs/fuse/passthrough.c
> @@ -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;
> -

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN
  2024-09-13 11:04 ` Amir Goldstein
@ 2024-09-13 11:12   ` Miklos Szeredi
  2024-09-13 11:44     ` Amir Goldstein
  0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2024-09-13 11:12 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Miklos Szeredi, linux-fsdevel

On Fri, 13 Sept 2024 at 13:05, Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Fri, Sep 13, 2024 at 12:50 PM Miklos Szeredi <mszeredi@redhat.com> wrote:

> > -       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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN
  2024-09-13 11:12   ` Miklos Szeredi
@ 2024-09-13 11:44     ` Amir Goldstein
  0 siblings, 0 replies; 4+ messages in thread
From: Amir Goldstein @ 2024-09-13 11:44 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Miklos Szeredi, linux-fsdevel

On Fri, Sep 13, 2024 at 1:13 PM Miklos Szeredi <miklos@szeredi.hu> wrote:
>
> On Fri, 13 Sept 2024 at 13:05, Amir Goldstein <amir73il@gmail.com> wrote:
> >
> > On Fri, Sep 13, 2024 at 12:50 PM Miklos Szeredi <mszeredi@redhat.com> wrote:
>
> > > -       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.
>
> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-13 11:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-13 10:47 [PATCH] fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN Miklos Szeredi
2024-09-13 11:04 ` Amir Goldstein
2024-09-13 11:12   ` Miklos Szeredi
2024-09-13 11:44     ` Amir Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).