* Re: [PATCH] virtio-scsi: Fix hotcpu_notifier use-after-free with virtscsi_freeze
[not found] <1382947263-22145-1-git-send-email-asias@redhat.com>
@ 2013-10-28 10:29 ` Paolo Bonzini
0 siblings, 0 replies; only message in thread
From: Paolo Bonzini @ 2013-10-28 10:29 UTC (permalink / raw)
To: Asias He
Cc: kvm, Rusty Russell, nab, linux-scsi, virtualization, Jason Wang,
stable
Il 28/10/2013 09:01, Asias He ha scritto:
> vqs are freed in virtscsi_freeze but the hotcpu_notifier is not
> unregistered. We will have a use-after-free usage when the notifier
> callback is called after virtscsi_freeze.
>
> Signed-off-by: Asias He <asias@redhat.com>
> ---
> drivers/scsi/virtio_scsi.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 74b88ef..b26f1a5 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -957,6 +957,10 @@ static void virtscsi_remove(struct virtio_device *vdev)
> #ifdef CONFIG_PM
> static int virtscsi_freeze(struct virtio_device *vdev)
> {
> + struct Scsi_Host *sh = virtio_scsi_host(vdev);
> + struct virtio_scsi *vscsi = shost_priv(sh);
> +
> + unregister_hotcpu_notifier(&vscsi->nb);
> virtscsi_remove_vqs(vdev);
> return 0;
> }
> @@ -965,8 +969,17 @@ static int virtscsi_restore(struct virtio_device *vdev)
> {
> struct Scsi_Host *sh = virtio_scsi_host(vdev);
> struct virtio_scsi *vscsi = shost_priv(sh);
> + int err;
> +
> + err = virtscsi_init(vdev, vscsi);
> + if (err)
> + return err;
> +
> + err = register_hotcpu_notifier(&vscsi->nb);
> + if (err)
> + vdev->config->del_vqs(vdev);
>
> - return virtscsi_init(vdev, vscsi);
> + return err;
> }
> #endif
>
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-10-28 10:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1382947263-22145-1-git-send-email-asias@redhat.com>
2013-10-28 10:29 ` [PATCH] virtio-scsi: Fix hotcpu_notifier use-after-free with virtscsi_freeze Paolo Bonzini
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).