[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 4/7] vhost-user: Fix userfaultfd leak
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PULL 4/7] vhost-user: Fix userfaultfd leak |
Date: |
Thu, 11 Oct 2018 20:25:10 +0100 |
From: Ilya Maximets <address@hidden>
'fd' received from the vhost side is never freed.
Also, everything (including 'postcopy_listen' state) should be
cleaned up on vhost cleanup.
Fixes: 46343570c06e ("vhost+postcopy: Wire up POSTCOPY_END notify")
Fixes: f82c11165ffa ("vhost+postcopy: Register shared ufd with postcopy")
Cc: address@hidden
Signed-off-by: Ilya Maximets <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Maxime Coquelin <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
hw/virtio/vhost-user.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index b041343632..ed47d645d9 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1291,6 +1291,7 @@ static int vhost_user_postcopy_end(struct vhost_dev *dev,
Error **errp)
return ret;
}
postcopy_unregister_shared_ufd(&u->postcopy_fd);
+ close(u->postcopy_fd.fd);
u->postcopy_fd.handler = NULL;
trace_vhost_user_postcopy_end_exit();
@@ -1430,6 +1431,12 @@ static int vhost_user_backend_cleanup(struct vhost_dev
*dev)
postcopy_remove_notifier(&u->postcopy_notifier);
u->postcopy_notifier.notify = NULL;
}
+ u->postcopy_listen = false;
+ if (u->postcopy_fd.handler) {
+ postcopy_unregister_shared_ufd(&u->postcopy_fd);
+ close(u->postcopy_fd.fd);
+ u->postcopy_fd.handler = NULL;
+ }
if (u->slave_fd >= 0) {
qemu_set_fd_handler(u->slave_fd, NULL, NULL, NULL);
close(u->slave_fd);
--
2.19.0
- [Qemu-devel] [PULL 0/7] migration queue, Dr. David Alan Gilbert (git), 2018/10/11
- [Qemu-devel] [PULL 3/7] migration: Stop postcopy fault thread before notifying, Dr. David Alan Gilbert (git), 2018/10/11
- [Qemu-devel] [PULL 4/7] vhost-user: Fix userfaultfd leak,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PULL 5/7] vhost-user: Don't ask for reply on postcopy mem table set, Dr. David Alan Gilbert (git), 2018/10/11
- [Qemu-devel] [PULL 6/7] qmp, hmp: make subsystem/system-vendor identities optional, Dr. David Alan Gilbert (git), 2018/10/11
- [Qemu-devel] [PULL 2/7] tests/migration: Enable the migration test on s390x, too, Dr. David Alan Gilbert (git), 2018/10/11
- Re: [Qemu-devel] [PULL 2/7] tests/migration: Enable the migration test on s390x, too, Emilio G. Cota, 2018/10/17
- Re: [Qemu-devel] [PULL 2/7] tests/migration: Enable the migration test on s390x, too, Thomas Huth, 2018/10/18
- Re: [Qemu-devel] [PULL 2/7] tests/migration: Enable the migration test on s390x, too, Thomas Huth, 2018/10/18
- Re: [Qemu-devel] [PULL 2/7] tests/migration: Enable the migration test on s390x, too, Emilio G. Cota, 2018/10/18
- Re: [Qemu-devel] [PULL 2/7] tests/migration: Enable the migration test on s390x, too, Wei Huang, 2018/10/18
- Re: [Qemu-devel] [PULL 2/7] tests/migration: Enable the migration test on s390x, too, Thomas Huth, 2018/10/19
[Qemu-devel] [PULL 1/7] tests: Add migration test for aarch64, Dr. David Alan Gilbert (git), 2018/10/11