* [Qemu-devel] [PATCH] virtio-serial-bus: Unset hotplug handler when unrealize
@ 2017-05-30 8:59 Ladi Prosek
2017-05-30 10:05 ` Paolo Bonzini
2017-05-30 11:35 ` Fam Zheng
0 siblings, 2 replies; 3+ messages in thread
From: Ladi Prosek @ 2017-05-30 8:59 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, famz, pbonzini, mst
Virtio serial device controls the lifetime of virtio-serial-bus and
virtio-serial-bus links back to the device via its hotplug-handler
property. This extra ref-count prevents the device from getting
finalized, leaving the VirtIODevice memory listener registered and
leading to use-after-free later on.
This patch addresses the same issue as Fam Zheng's
"virtio-scsi: Unset hotplug handler when unrealize"
only for a different virtio device.
Cc: qemu-stable@nongnu.org
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
---
hw/char/virtio-serial-bus.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index d797a67..aa9c11a 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -1121,6 +1121,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
timer_free(vser->post_load->timer);
g_free(vser->post_load);
}
+
+ qbus_set_hotplug_handler(BUS(&vser->bus), NULL, errp);
+
virtio_cleanup(vdev);
}
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-serial-bus: Unset hotplug handler when unrealize
2017-05-30 8:59 [Qemu-devel] [PATCH] virtio-serial-bus: Unset hotplug handler when unrealize Ladi Prosek
@ 2017-05-30 10:05 ` Paolo Bonzini
2017-05-30 11:35 ` Fam Zheng
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2017-05-30 10:05 UTC (permalink / raw)
To: Ladi Prosek, qemu-devel; +Cc: qemu-stable, famz, mst
On 30/05/2017 10:59, Ladi Prosek wrote:
> Virtio serial device controls the lifetime of virtio-serial-bus and
> virtio-serial-bus links back to the device via its hotplug-handler
> property. This extra ref-count prevents the device from getting
> finalized, leaving the VirtIODevice memory listener registered and
> leading to use-after-free later on.
>
> This patch addresses the same issue as Fam Zheng's
> "virtio-scsi: Unset hotplug handler when unrealize"
> only for a different virtio device.
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Ladi Prosek <lprosek@redhat.com>
> ---
> hw/char/virtio-serial-bus.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index d797a67..aa9c11a 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -1121,6 +1121,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
> timer_free(vser->post_load->timer);
> g_free(vser->post_load);
> }
> +
> + qbus_set_hotplug_handler(BUS(&vser->bus), NULL, errp);
> +
> virtio_cleanup(vdev);
> }
>
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-serial-bus: Unset hotplug handler when unrealize
2017-05-30 8:59 [Qemu-devel] [PATCH] virtio-serial-bus: Unset hotplug handler when unrealize Ladi Prosek
2017-05-30 10:05 ` Paolo Bonzini
@ 2017-05-30 11:35 ` Fam Zheng
1 sibling, 0 replies; 3+ messages in thread
From: Fam Zheng @ 2017-05-30 11:35 UTC (permalink / raw)
To: Ladi Prosek; +Cc: qemu-devel, pbonzini, qemu-stable, mst
On Tue, 05/30 10:59, Ladi Prosek wrote:
> Virtio serial device controls the lifetime of virtio-serial-bus and
> virtio-serial-bus links back to the device via its hotplug-handler
> property. This extra ref-count prevents the device from getting
> finalized, leaving the VirtIODevice memory listener registered and
> leading to use-after-free later on.
>
> This patch addresses the same issue as Fam Zheng's
> "virtio-scsi: Unset hotplug handler when unrealize"
> only for a different virtio device.
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Ladi Prosek <lprosek@redhat.com>
> ---
> hw/char/virtio-serial-bus.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index d797a67..aa9c11a 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -1121,6 +1121,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
> timer_free(vser->post_load->timer);
> g_free(vser->post_load);
> }
> +
> + qbus_set_hotplug_handler(BUS(&vser->bus), NULL, errp);
> +
> virtio_cleanup(vdev);
> }
>
> --
> 2.9.3
>
>
Reviewed-by: Fam Zheng <famz@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-30 11:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-30 8:59 [Qemu-devel] [PATCH] virtio-serial-bus: Unset hotplug handler when unrealize Ladi Prosek
2017-05-30 10:05 ` Paolo Bonzini
2017-05-30 11:35 ` Fam Zheng
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).