Skip to content
Snippets Groups Projects
Commit a4a50214 authored by Ilya Maximets's avatar Ilya Maximets Committed by Michael Roth
Browse files

vhost-user: Fix userfaultfd leak


'fd' received from the vhost side is never freed.
Also, everything (including 'postcopy_listen' state) should be
cleaned up on vhost cleanup.

Fixes: 46343570 ("vhost+postcopy: Wire up POSTCOPY_END notify")
Fixes: f82c1116 ("vhost+postcopy: Register shared ufd with postcopy")
Cc: qemu-stable@nongnu.org
Signed-off-by: default avatarIlya Maximets <i.maximets@samsung.com>
Message-Id: <20181008160536.6332-3-i.maximets@samsung.com>
Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: default avatarMaxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
(cherry picked from commit c4f75385)
Signed-off-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
parent a0380bda
No related branches found
No related tags found
No related merge requests found
...@@ -1280,6 +1280,7 @@ static int vhost_user_postcopy_end(struct vhost_dev *dev, Error **errp) ...@@ -1280,6 +1280,7 @@ static int vhost_user_postcopy_end(struct vhost_dev *dev, Error **errp)
return ret; return ret;
} }
postcopy_unregister_shared_ufd(&u->postcopy_fd); postcopy_unregister_shared_ufd(&u->postcopy_fd);
close(u->postcopy_fd.fd);
u->postcopy_fd.handler = NULL; u->postcopy_fd.handler = NULL;
trace_vhost_user_postcopy_end_exit(); trace_vhost_user_postcopy_end_exit();
...@@ -1419,6 +1420,12 @@ static int vhost_user_backend_cleanup(struct vhost_dev *dev) ...@@ -1419,6 +1420,12 @@ static int vhost_user_backend_cleanup(struct vhost_dev *dev)
postcopy_remove_notifier(&u->postcopy_notifier); postcopy_remove_notifier(&u->postcopy_notifier);
u->postcopy_notifier.notify = NULL; 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) { if (u->slave_fd >= 0) {
qemu_set_fd_handler(u->slave_fd, NULL, NULL, NULL); qemu_set_fd_handler(u->slave_fd, NULL, NULL, NULL);
close(u->slave_fd); close(u->slave_fd);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment