[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 32/34] vhost: remove assertion to prevent crash
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 32/34] vhost: remove assertion to prevent crash |
Date: |
Tue, 16 Jan 2018 19:53:06 +0200 |
From: Jay Zhou <address@hidden>
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: address@hidden
Signed-off-by: Igor Mammedov <address@hidden>
Signed-off-by: Jay Zhou <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
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 7930fd8..6eb9798 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -342,11 +342,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;
}
}
--
MST
- [Qemu-devel] [PULL v2 22/34] vhost: Simplify ring verification checks, (continued)
- [Qemu-devel] [PULL v2 22/34] vhost: Simplify ring verification checks, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 21/34] vhost: Build temporary section list and deref after commit, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 23/34] vhost: Merge sections added to temporary list, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 24/34] x86_iommu: Move machine check to x86_iommu_realize(), Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 25/34] x86_iommu: check if machine has PCI bus, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 26/34] tests: acpi: move tested tables array allocation outside of test_acpi_dsdt_table(), Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 28/34] tests: acpi: rename test_acpi_tables()/test_dst_table() to reflect its usage, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 27/34] tests: acpi: init table descriptor in test_dst_table(), Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 29/34] tests: acpi: add comments to fetch_rsdt_referenced_tables/data->tables usage, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 30/34] vhost-user: factor out msg head and payload, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 32/34] vhost: remove assertion to prevent crash,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 33/34] vhost: fix memslot limit check, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 31/34] vhost-user: fix misaligned access to payload, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 34/34] vhost: used_memslots refactoring, Michael S. Tsirkin, 2018/01/16
- Re: [Qemu-devel] [PULL v2 00/34] pc, pci, virtio: features, fixes, cleanups, Peter Maydell, 2018/01/18
- Re: [Qemu-devel] [PULL v2 00/34] pc, pci, virtio: features, fixes, cleanups, Michael S. Tsirkin, 2018/01/18
- Re: [Qemu-devel] [PULL v2 00/34] pc, pci, virtio: features, fixes, cleanups, Michael S. Tsirkin, 2018/01/18