|
Pablo Greco |
e6a3ae |
From 8c80943cfe6e8e50f0a18cc2b4f09f9eefed47dc Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
e6a3ae |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Date: Tue, 26 Nov 2019 16:29:02 +0000
|
|
Pablo Greco |
e6a3ae |
Subject: [PATCH 16/16] vhost: fix vhost_log size overflow during migration
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Message-id: <20191126162902.46145-2-dgilbert@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Patchwork-id: 92689
|
|
Pablo Greco |
e6a3ae |
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/1] vhost: fix vhost_log size overflow during migration
|
|
Pablo Greco |
e6a3ae |
Bugzilla: 1776808
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
From: Li Hangjing <lihangjing@baidu.com>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
When a guest which doesn't support multiqueue is migrated with a multi queues
|
|
Pablo Greco |
e6a3ae |
vhost-user-blk deivce, a crash will occur like:
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
0 qemu_memfd_alloc (name=<value optimized out>, size=562949953421312, seals=<value optimized out>, fd=0x7f87171fe8b4, errp=0x7f87171fe8a8) at util/memfd.c:153
|
|
Pablo Greco |
e6a3ae |
1 0x00007f883559d7cf in vhost_log_alloc (size=70368744177664, share=true) at hw/virtio/vhost.c:186
|
|
Pablo Greco |
e6a3ae |
2 0x00007f88355a0758 in vhost_log_get (listener=0x7f8838bd7940, enable=1) at qemu-2-12/hw/virtio/vhost.c:211
|
|
Pablo Greco |
e6a3ae |
3 vhost_dev_log_resize (listener=0x7f8838bd7940, enable=1) at hw/virtio/vhost.c:263
|
|
Pablo Greco |
e6a3ae |
4 vhost_migration_log (listener=0x7f8838bd7940, enable=1) at hw/virtio/vhost.c:787
|
|
Pablo Greco |
e6a3ae |
5 0x00007f88355463d6 in memory_global_dirty_log_start () at memory.c:2503
|
|
Pablo Greco |
e6a3ae |
6 0x00007f8835550577 in ram_init_bitmaps (f=0x7f88384ce600, opaque=0x7f8836024098) at migration/ram.c:2173
|
|
Pablo Greco |
e6a3ae |
7 ram_init_all (f=0x7f88384ce600, opaque=0x7f8836024098) at migration/ram.c:2192
|
|
Pablo Greco |
e6a3ae |
8 ram_save_setup (f=0x7f88384ce600, opaque=0x7f8836024098) at migration/ram.c:2219
|
|
Pablo Greco |
e6a3ae |
9 0x00007f88357a419d in qemu_savevm_state_setup (f=0x7f88384ce600) at migration/savevm.c:1002
|
|
Pablo Greco |
e6a3ae |
10 0x00007f883579fc3e in migration_thread (opaque=0x7f8837530400) at migration/migration.c:2382
|
|
Pablo Greco |
e6a3ae |
11 0x00007f8832447893 in start_thread () from /lib64/libpthread.so.0
|
|
Pablo Greco |
e6a3ae |
12 0x00007f8832178bfd in clone () from /lib64/libc.so.6
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
This is because vhost_get_log_size() returns a overflowed vhost-log size.
|
|
Pablo Greco |
e6a3ae |
In this function, it uses the uninitialized variable vqs->used_phys and
|
|
Pablo Greco |
e6a3ae |
vqs->used_size to get the vhost-log size.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Li Hangjing <lihangjing@baidu.com>
|
|
Pablo Greco |
e6a3ae |
Reviewed-by: Xie Yongji <xieyongji@baidu.com>
|
|
Pablo Greco |
e6a3ae |
Reviewed-by: Chai Wen <chaiwen@baidu.com>
|
|
Pablo Greco |
e6a3ae |
Message-Id: <20190603061524.24076-1-lihangjing@baidu.com>
|
|
Pablo Greco |
e6a3ae |
Cc: qemu-stable@nongnu.org
|
|
Pablo Greco |
e6a3ae |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Pablo Greco |
e6a3ae |
(cherry picked from commit 240e647a14df9677b3a501f7b8b870e40aac3fd5)
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
Pablo Greco |
e6a3ae |
---
|
|
Pablo Greco |
e6a3ae |
hw/virtio/vhost.c | 10 ++++++++++
|
|
Pablo Greco |
e6a3ae |
1 file changed, 10 insertions(+)
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
|
|
Pablo Greco |
e6a3ae |
index 1ae68ff..7bdc9c4 100644
|
|
Pablo Greco |
e6a3ae |
--- a/hw/virtio/vhost.c
|
|
Pablo Greco |
e6a3ae |
+++ b/hw/virtio/vhost.c
|
|
Pablo Greco |
e6a3ae |
@@ -131,6 +131,11 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
for (i = 0; i < dev->nvqs; ++i) {
|
|
Pablo Greco |
e6a3ae |
struct vhost_virtqueue *vq = dev->vqs + i;
|
|
Pablo Greco |
e6a3ae |
+
|
|
Pablo Greco |
e6a3ae |
+ if (!vq->used_phys && !vq->used_size) {
|
|
Pablo Greco |
e6a3ae |
+ continue;
|
|
Pablo Greco |
e6a3ae |
+ }
|
|
Pablo Greco |
e6a3ae |
+
|
|
Pablo Greco |
e6a3ae |
vhost_dev_sync_region(dev, section, start_addr, end_addr, vq->used_phys,
|
|
Pablo Greco |
e6a3ae |
range_get_last(vq->used_phys, vq->used_size));
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
@@ -168,6 +173,11 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev)
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
for (i = 0; i < dev->nvqs; ++i) {
|
|
Pablo Greco |
e6a3ae |
struct vhost_virtqueue *vq = dev->vqs + i;
|
|
Pablo Greco |
e6a3ae |
+
|
|
Pablo Greco |
e6a3ae |
+ if (!vq->used_phys && !vq->used_size) {
|
|
Pablo Greco |
e6a3ae |
+ continue;
|
|
Pablo Greco |
e6a3ae |
+ }
|
|
Pablo Greco |
e6a3ae |
+
|
|
Pablo Greco |
e6a3ae |
uint64_t last = vq->used_phys + vq->used_size - 1;
|
|
Pablo Greco |
e6a3ae |
log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1);
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
--
|
|
Pablo Greco |
e6a3ae |
1.8.3.1
|
|
Pablo Greco |
e6a3ae |
|