diff options
author | Asias He <asias.hejun@gmail.com> | 2014-01-15 18:48:48 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2014-01-15 18:52:27 -0500 |
commit | f466f75385369a181409e46da272db3de6f5c5cb (patch) | |
tree | fa59806c3d5c387494e0cc0be2db726eb3ad5028 /drivers/scsi | |
parent | 7d2dddda5c928f349a01f1d5ca8ee5e9d4283c7a (diff) |
virtio-scsi: Fix hotcpu_notifier use-after-free with virtscsi_freeze
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.
Fixes: 285e71ea6f3583a85e27cb2b9a7d8c35d4c0d558
("virtio-scsi: reset virtqueue affinity when doing cpu hotplug")
Cc: stable@vger.kernel.org
Signed-off-by: Asias He <asias.hejun@gmail.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/virtio_scsi.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index c3173dced870..16bfd50cd3fe 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c | |||
@@ -956,6 +956,10 @@ static void virtscsi_remove(struct virtio_device *vdev) | |||
956 | #ifdef CONFIG_PM_SLEEP | 956 | #ifdef CONFIG_PM_SLEEP |
957 | static int virtscsi_freeze(struct virtio_device *vdev) | 957 | static int virtscsi_freeze(struct virtio_device *vdev) |
958 | { | 958 | { |
959 | struct Scsi_Host *sh = virtio_scsi_host(vdev); | ||
960 | struct virtio_scsi *vscsi = shost_priv(sh); | ||
961 | |||
962 | unregister_hotcpu_notifier(&vscsi->nb); | ||
959 | virtscsi_remove_vqs(vdev); | 963 | virtscsi_remove_vqs(vdev); |
960 | return 0; | 964 | return 0; |
961 | } | 965 | } |
@@ -964,8 +968,17 @@ static int virtscsi_restore(struct virtio_device *vdev) | |||
964 | { | 968 | { |
965 | struct Scsi_Host *sh = virtio_scsi_host(vdev); | 969 | struct Scsi_Host *sh = virtio_scsi_host(vdev); |
966 | struct virtio_scsi *vscsi = shost_priv(sh); | 970 | struct virtio_scsi *vscsi = shost_priv(sh); |
971 | int err; | ||
972 | |||
973 | err = virtscsi_init(vdev, vscsi); | ||
974 | if (err) | ||
975 | return err; | ||
976 | |||
977 | err = register_hotcpu_notifier(&vscsi->nb); | ||
978 | if (err) | ||
979 | vdev->config->del_vqs(vdev); | ||
967 | 980 | ||
968 | return virtscsi_init(vdev, vscsi); | 981 | return err; |
969 | } | 982 | } |
970 | #endif | 983 | #endif |
971 | 984 | ||