[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/10] virtio/vhost-user: Fix wrong vhost notifier GPtrArray size
From: |
Michael S. Tsirkin |
Subject: |
[PULL 04/10] virtio/vhost-user: Fix wrong vhost notifier GPtrArray size |
Date: |
Thu, 16 Jun 2022 12:57:33 -0400 |
From: Yajun Wu <yajunw@nvidia.com>
In fetch_or_create_notifier, idx begins with 0. So the GPtrArray size
should be idx + 1 and g_ptr_array_set_size should be called with idx + 1.
This wrong GPtrArray size causes fetch_or_create_notifier return an invalid
address. Passing this invalid pointer to vhost_user_host_notifier_remove
causes assert fail:
qemu/include/qemu/int128.h:27: int128_get64: Assertion `r == a' failed.
shutting down, reason=crashed
Backends like dpdk-vdpa which sends out vhost notifier requests almost always
hit qemu crash.
Fixes: 503e355465 ("virtio/vhost-user: dynamically assign
VhostUserHostNotifiers")
Signed-off-by: Yajun Wu <yajunw@nvidia.com>
Acked-by: Parav Pandit <parav@nvidia.com>
Change-Id: I87e0f7591ca9a59d210879b260704a2d9e9d6bcd
Message-Id: <20220526034851.683258-1-yajunw@nvidia.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
---
hw/virtio/vhost-user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 0594178224..4b9be26e84 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1525,7 +1525,7 @@ static VhostUserHostNotifier
*fetch_or_create_notifier(VhostUserState *u,
{
VhostUserHostNotifier *n = NULL;
if (idx >= u->notifiers->len) {
- g_ptr_array_set_size(u->notifiers, idx);
+ g_ptr_array_set_size(u->notifiers, idx + 1);
}
n = g_ptr_array_index(u->notifiers, idx);
--
MST
- [PULL 00/10] virtio,pc,pci: fixes,cleanups,features, Michael S. Tsirkin, 2022/06/16
- [PULL 01/10] pci-bridge/cxl_upstream: Add a CXL switch upstream port, Michael S. Tsirkin, 2022/06/16
- [PULL 02/10] pci-bridge/cxl_downstream: Add a CXL switch downstream port, Michael S. Tsirkin, 2022/06/16
- [PULL 03/10] docs/cxl: Add switch documentation, Michael S. Tsirkin, 2022/06/16
- [PULL 04/10] virtio/vhost-user: Fix wrong vhost notifier GPtrArray size,
Michael S. Tsirkin <=
- [PULL 06/10] virtio-iommu: Use recursive lock to avoid deadlock, Michael S. Tsirkin, 2022/06/16
- [PULL 05/10] virtio-iommu: Add bypass mode support to assigned device, Michael S. Tsirkin, 2022/06/16
- [PULL 07/10] virtio-iommu: Add an assert check in translate routine, Michael S. Tsirkin, 2022/06/16
- [PULL 10/10] acpi/erst: fix fallthrough code upon validation failure, Michael S. Tsirkin, 2022/06/16
- [PULL 09/10] vhost: also check queue state in the vhost_dev_set_log error routine, Michael S. Tsirkin, 2022/06/16
- [PULL 08/10] crypto: Introduce RSA algorithm, Michael S. Tsirkin, 2022/06/16
- Re: [PULL 00/10] virtio,pc,pci: fixes,cleanups,features, Richard Henderson, 2022/06/16