From: Stefan Hajnoczi <stefanha@gmail.com>
To: pannengyuan@huawei.com
Cc: zhang.zhanghailiang@huawei.com,
Euler Robot <euler.robot@huawei.com>,
qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [PATCH v2] vhost-vsock: delete vqs in vhost_vsock_unrealize to avoid memleaks
Date: Mon, 20 Jan 2020 10:41:51 +0000 [thread overview]
Message-ID: <20200120104151.GF345995@stefanha-x1.localdomain> (raw)
In-Reply-To: <20200115062535.50644-1-pannengyuan@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 1560 bytes --]
On Wed, Jan 15, 2020 at 02:25:35PM +0800, pannengyuan@huawei.com wrote:
> From: Pan Nengyuan <pannengyuan@huawei.com>
>
> Receive/transmit/event vqs forgot to cleanup in vhost_vsock_unrealize. This
> patch save receive/transmit vq pointer in realize() and cleanup vqs
> through those vq pointers in unrealize(). The leak stack is as follow:
>
> Direct leak of 21504 byte(s) in 3 object(s) allocated from:
> #0 0x7f86a1356970 (/lib64/libasan.so.5+0xef970) ??:?
> #1 0x7f86a09aa49d (/lib64/libglib-2.0.so.0+0x5249d) ??:?
> #2 0x5604852f85ca (./x86_64-softmmu/qemu-system-x86_64+0x2c3e5ca) /mnt/sdb/qemu/hw/virtio/virtio.c:2333
> #3 0x560485356208 (./x86_64-softmmu/qemu-system-x86_64+0x2c9c208) /mnt/sdb/qemu/hw/virtio/vhost-vsock.c:339
> #4 0x560485305a17 (./x86_64-softmmu/qemu-system-x86_64+0x2c4ba17) /mnt/sdb/qemu/hw/virtio/virtio.c:3531
> #5 0x5604858e6b65 (./x86_64-softmmu/qemu-system-x86_64+0x322cb65) /mnt/sdb/qemu/hw/core/qdev.c:865
> #6 0x5604861e6c41 (./x86_64-softmmu/qemu-system-x86_64+0x3b2cc41) /mnt/sdb/qemu/qom/object.c:2102
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> ---
> Changes V2 to V1:
> - delete virtqueues after vhost cleanup to avoid use-after-free
> - aslo delete virtqueues in the error path of realize()
> ---
> hw/virtio/vhost-vsock.c | 12 ++++++++++--
> include/hw/virtio/vhost-vsock.h | 2 ++
> 2 files changed, 12 insertions(+), 2 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2020-01-20 11:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 6:25 [PATCH v2] vhost-vsock: delete vqs in vhost_vsock_unrealize to avoid memleaks pannengyuan
2020-01-15 8:41 ` Stefano Garzarella
2020-01-20 10:41 ` Stefan Hajnoczi [this message]
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=20200120104151.GF345995@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=euler.robot@huawei.com \
--cc=mst@redhat.com \
--cc=pannengyuan@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=zhang.zhanghailiang@huawei.com \
/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 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).