All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: Li Qiang <liq3ea@gmail.com>
Cc: QEMU <qemu-devel@nongnu.org>, Li Qiang <liq3ea@163.com>,
	Gerd Hoffmann <kraxel@redhat.com>, P J P <ppandit@redhat.com>
Subject: Re: [PATCH 6/7] vhost-user-gpu: fix memory leak in 'virgl_resource_attach_backing'
Date: Wed, 5 May 2021 13:33:10 +0400	[thread overview]
Message-ID: <CAJ+F1C+j1VJjkgx49eTQmya07jxS0vSDivnrqduuZkMA8SkNmA@mail.gmail.com> (raw)
In-Reply-To: <CAKXe6SLmbnmBs2NhyP=8Vm51wQXxFKW9m2XAYYcVTb3dpmEsYg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2457 bytes --]

Hi

On Wed, May 5, 2021 at 1:24 PM Li Qiang <liq3ea@gmail.com> wrote:

> Marc-André Lureau <marcandre.lureau@gmail.com> 于2021年5月5日周三 下午5:08写道:
> >
> > Hi
> >
> > On Wed, May 5, 2021 at 12:03 PM P J P <ppandit@redhat.com> wrote:
> >>
> >> +-- On Tue, 4 May 2021, Li Qiang wrote --+
> >> | diff --git a/contrib/vhost-user-gpu/virgl.c
> b/contrib/vhost-user-gpu/virgl.c
> >> | index c669d73a1d..a16a311d80 100644
> >> | --- a/contrib/vhost-user-gpu/virgl.c
> >> | +++ b/contrib/vhost-user-gpu/virgl.c
> >> | @@ -287,8 +287,11 @@ virgl_resource_attach_backing(VuGpu *g,
> >> |          return;
> >> |      }
> >> |
> >> | -    virgl_renderer_resource_attach_iov(att_rb.resource_id,
> >> | +    ret = virgl_renderer_resource_attach_iov(att_rb.resource_id,
> >> |                                         res_iovs, att_rb.nr_entries);
> >> | +    if (ret != 0) {
> >> | +        g_free(res_iovs);
> >> | +    }
> >> |  }
> >>
> >> * Similar to earlier,
> >>   hw/display/virtio-gpu-3d.c:virgl_resource_attach_backing() calls
> >>   'virtio_gpu_cleanup_mapping_iov'
> >>
> >> * should it be same for vhost-user-gpu?
> >>
> >>
> >
> > Good question, that's also what you did when you fixed it for virtio-gpu
> in:
> >
> > commit 33243031dad02d161225ba99d782616da133f689
> > Author: Li Qiang <liq3ea@gmail.com>
> > Date:   Thu Dec 29 03:11:26 2016 -0500
> >
> >     virtio-gpu-3d: fix memory leak in resource attach backing
> >
>
> Do you mean this;
> -->https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg01156.html
>
> I think there is no need for this.
>
> The virtio_gpu_cleanup_mapping_iov is needed in virtio-gpu is because
> it need map guest memory.
> But in vhost-user-gpu case, the 'vg_create_mapping_iov' calls
> 'vu_gpa_to_va' and this function don't need
> do map memory.
>
> But for the beauty of symmetry we can abstract a function called
> 'vg_destroy_mapping_iov' and it just calls g_free(res->iov).
> Like the pair 'virtio_gpu_create_mapping_iov' and
> 'virtio_gpu_cleanup_mapping'.
>
>
Right. I think I like the suggestion to add a 'virtio_gpu_cleanup_mapping'
(with a comment to explain it) to avoid this kind of question again. Feel
free to add a patch on top if you want.

thanks


>
> >
> > Btw, for each patch, it would be nice to have a reference to the
> original fix in virtio-gpu.
> >
> > Thanks!
> >
>


-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 3752 bytes --]

  reply	other threads:[~2021-05-05  9:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05  4:58 [PATCH 0/7] vhost-user-gpu: fix several security issues Li Qiang
2021-05-05  4:58 ` [PATCH 1/7] vhost-user-gpu: fix memory disclosure in virgl_cmd_get_capset_info Li Qiang
2021-05-05  7:23   ` P J P
2021-05-05  9:07     ` Li Qiang
2021-05-06  5:53       ` P J P
2021-05-06  7:49         ` Li Qiang
2021-05-05  4:58 ` [PATCH 2/7] vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' Li Qiang
2021-05-05  7:28   ` P J P
2021-05-05  4:58 ` [PATCH 3/7] vhost-user-gpu: fix memory leak in vg_resource_attach_backing Li Qiang
2021-05-05  7:39   ` P J P
2021-05-05  9:11     ` Li Qiang
2021-05-05  4:58 ` [PATCH 4/7] vhost-user-gpu: fix memory link while calling 'vg_resource_unref' Li Qiang
2021-05-05  7:42   ` P J P
2021-05-05  4:58 ` [PATCH 5/7] vhost-user-gpu: fix memory leak in 'virgl_cmd_resource_unref' Li Qiang
2021-05-05  7:48   ` P J P
2021-05-05  9:14     ` Li Qiang
2021-05-05  4:58 ` [PATCH 6/7] vhost-user-gpu: fix memory leak in 'virgl_resource_attach_backing' Li Qiang
2021-05-05  7:55   ` P J P
2021-05-05  9:07     ` Marc-André Lureau
2021-05-05  9:23       ` Li Qiang
2021-05-05  9:33         ` Marc-André Lureau [this message]
2021-05-05  4:58 ` [PATCH 7/7] vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset' Li Qiang
2021-05-05  7:58   ` P J P
2021-05-05  9:10 ` [PATCH 0/7] vhost-user-gpu: fix several security issues Marc-André Lureau
2021-05-05  9:27   ` Li Qiang
2021-05-05  9:35     ` Marc-André Lureau
2021-05-10 19:25       ` Philippe Mathieu-Daudé
2021-05-11  2:49         ` Li Qiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ+F1C+j1VJjkgx49eTQmya07jxS0vSDivnrqduuZkMA8SkNmA@mail.gmail.com \
    --to=marcandre.lureau@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=liq3ea@163.com \
    --cc=liq3ea@gmail.com \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.