[Virtio-fs] [PATCH] virtiofsd: handle NULL dir in lo_do_lookup

Eryu Guan eguan at linux.alibaba.com
Thu May 23 03:22:54 UTC 2019


On Thu, May 23, 2019 at 10:06:34AM +0800, Liu Bo wrote:
> Reported by fstests/generic/467.
> 
> open_by_handle_at() called from fuse inside guest can carry fuse mount
> point to daemon but lo_do_lookup() doesn't know its inode info because
> it's out of fuse's scope, thus lo_inode(req, parent) ends up with
> returning a NULL dir and breaks virtiofsd immediately.
> 
> Note that it'd break applications that uses open_by_handle_at.
> 
> It seems to me that nothing could be done to support open_by_handle_at in
> this case.

Then perhaps we should consider disabling exportfs support in virtio-fs
case? I noticed that currently fuse set

	sb->s_export_op = &fuse_export_operations

unconditionally, maybe we could implement a feature mask in fuse and let
filesystem implementation registers what features it supports, e.g.
exportfs in this case.

Or we could try adding real exportfs support to virtiofs? Though I'm not
sure if it's possible or worth it at the moment.

> 
> This simply tells fuse a ENOENT error so that open_by_handle_at() in guest
> can get a ESTALE.
> 
> Signed-off-by: Liu Bo <bo.liu at linux.alibaba.com>

The patch itself looks fine to me.

Reviewed-by: Eryu Guan <eguan at linux.alibaba.com>

Thanks,
Eryu

> ---
>  contrib/virtiofsd/passthrough_ll.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c
> index 9b7e515..b58708f 100644
> --- a/contrib/virtiofsd/passthrough_ll.c
> +++ b/contrib/virtiofsd/passthrough_ll.c
> @@ -640,6 +640,14 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
>  	struct lo_data *lo = lo_data(req);
>  	struct lo_inode *inode, *dir = lo_inode(req, parent);
>  
> +        /*
> +         * name_to_handle_at() and open_by_handle_at() can reach here with fuse
> +         * mount point in guest, but we don't have its inode info in the
> +         * ino_map.
> +         */
> +        if (!dir)
> +                return ENOENT;
> +
>  	memset(e, 0, sizeof(*e));
>  	e->attr_timeout = lo->timeout;
>  	e->entry_timeout = lo->timeout;
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Virtio-fs mailing list
> Virtio-fs at redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs




More information about the Virtio-fs mailing list