From: Liu Bo <[email protected]>
Sent: Friday, May 15, 2020 06:48
To: Fotis Xenakis <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [Virtio-fs] [PATCH] Fix file descriptor passed for setupmapping

On Wed, May 13, 2020 at 07:33:56PM +0300, Fotis Xenakis wrote:
> Currently, during FUSE_SETUPMAPPING, virtiofsd passes the wrong file
> descriptor for the file to mmap() to QEMU (specifically, it passes the
> file handle as requested from the guest).
>
> This fixes it, using lo_fi_fd() to map the file handle to the right file
> descriptor on the host.
>

Looks good, guest has been setting fi as NULL though.
As far as I can see, this function is only called from [1], which passes fi as 
NULL only when the file handle passed from the guest is (uint64_t)-1. In my 
testing this was never the case though.

Reference:
[1] 
https://gitlab.com/virtio-fs/qemu/-/blob/21336c0f3d05a97f5c409bbc894c19d87259655c/tools/virtiofsd/fuse_lowlevel.c#L1930
Reviewed-by: Liu Bo <[email protected]>


> Signed-off-by: Fotis Xenakis <[email protected]>
> ---
>  tools/virtiofsd/passthrough_ll.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/virtiofsd/passthrough_ll.c 
> b/tools/virtiofsd/passthrough_ll.c
> index e09d557d74..44bb24eb5e 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -2709,7 +2709,7 @@ static void lo_setupmapping(fuse_req_t req, fuse_ino_t 
> ino, uint64_t foffset,
>      msg.flags[0] = vhu_flags;
>
>      if (fi) {
> -        fd = fi->fh;
> +        fd = lo_fi_fd(req, fi);
>      } else {
>          res = asprintf(&buf, "%i", lo_fd(req, ino));
>          if (res == -1) {
> --
> 2.26.2
>
>
> _______________________________________________
> Virtio-fs mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/virtio-fs
_______________________________________________
Virtio-fs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virtio-fs

Reply via email to