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

[Xen-changelog] [qemu-xen master] vhost: remove assertion to prevent crash



commit 88bf4a70dfc5a552a2683e8ae861453e1d385a23
Author:     Jay Zhou <jianjay.zhou@xxxxxxxxxx>
AuthorDate: Fri Jan 12 10:47:57 2018 +0800
Commit:     Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
CommitDate: Tue Jan 23 16:30:56 2018 -0600

    vhost: remove assertion to prevent crash
    
    QEMU will assert on vhost-user backed virtio device hotplug if QEMU is
    using more RAM regions than VHOST_MEMORY_MAX_NREGIONS (for example if
    it were started with a lot of DIMM devices).
    
    Fix it by returning error instead of asserting and let callers of
    vhost_set_mem_table() handle error condition gracefully.
    
    Cc: qemu-stable@xxxxxxxxxx
    Signed-off-by: Igor Mammedov <imammedo@xxxxxxxxxx>
    Signed-off-by: Jay Zhou <jianjay.zhou@xxxxxxxxxx>
    Reviewed-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    (cherry picked from commit f4bf56fb78ed0e9f60fa1ed656c14ff4c494da5a)
    Signed-off-by: Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
---
 hw/virtio/vhost-user.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 093675e..8500562 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -317,11 +317,14 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev,
                                      &offset);
         fd = memory_region_get_fd(mr);
         if (fd > 0) {
+            if (fd_num == VHOST_MEMORY_MAX_NREGIONS) {
+                error_report("Failed preparing vhost-user memory table msg");
+                return -1;
+            }
             msg.payload.memory.regions[fd_num].userspace_addr = 
reg->userspace_addr;
             msg.payload.memory.regions[fd_num].memory_size  = reg->memory_size;
             msg.payload.memory.regions[fd_num].guest_phys_addr = 
reg->guest_phys_addr;
             msg.payload.memory.regions[fd_num].mmap_offset = offset;
-            assert(fd_num < VHOST_MEMORY_MAX_NREGIONS);
             fds[fd_num++] = fd;
         }
     }
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.