qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] virtio/vhost: reset dev->log after syncing


From: Jason Wang
Subject: Re: [Qemu-devel] [PATCH] virtio/vhost: reset dev->log after syncing
Date: Thu, 21 Sep 2017 09:47:46 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0



On 2017年09月21日 02:53, Felipe Franciosi wrote:
vhost_log_put() is called to decomission the dirty log between qemu and
a vhost device when stopping the device. Such a call can happen from
migration_completion().

Present code sets dev->log_size to zero too early in vhost_log_put(),
causing the sync check to always return false. As a consequence, the
last pass on the dirty bitmap never happens at the end of migration.

If a vhost device was busy (writing to guest memory) until the last
moments before vhost_virtqueue_stop(), this error will result in guest
memory corruption (at least) following migrations.

Signed-off-by: Felipe Franciosi <address@hidden>
---
  hw/virtio/vhost.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 5fd69f0..ddc42f0 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -375,8 +375,6 @@ static void vhost_log_put(struct vhost_dev *dev, bool sync)
      if (!log) {
          return;
      }
-    dev->log = NULL;
-    dev->log_size = 0;
--log->refcnt;
      if (log->refcnt == 0) {
@@ -396,6 +394,9 @@ static void vhost_log_put(struct vhost_dev *dev, bool sync)
g_free(log);
      }
+
+    dev->log = NULL;
+    dev->log_size = 0;
  }
static bool vhost_dev_log_is_shared(struct vhost_dev *dev)

Cc: address@hidden

Acked-by: Jason Wang <address@hidden>

Thanks



reply via email to

[Prev in Thread] Current Thread [Next in Thread]