]> git.proxmox.com Git - mirror_qemu.git/commit
vhost-vdpa: do not cleanup the vdpa/vhost-net structures if peer nic is present
authorAni Sinha <anisinha@redhat.com>
Mon, 19 Jun 2023 06:52:09 +0000 (12:22 +0530)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 26 Jun 2023 13:50:00 +0000 (09:50 -0400)
commita0d7215e339b61c7d7a7b3fcf754954d80d93eb8
tree644daba7c5c47bdb59b7283e6d86dd20eede58dc
parent0e994668d00c9ca760817a4ae802a7bed0e29596
vhost-vdpa: do not cleanup the vdpa/vhost-net structures if peer nic is present

When a peer nic is still attached to the vdpa backend, it is too early to free
up the vhost-net and vdpa structures. If these structures are freed here, then
QEMU crashes when the guest is being shut down. The following call chain
would result in an assertion failure since the pointer returned from
vhost_vdpa_get_vhost_net() would be NULL:

do_vm_stop() -> vm_state_notify() -> virtio_set_status() ->
virtio_net_vhost_status() -> get_vhost_net().

Therefore, we defer freeing up the structures until at guest shutdown
time when qemu_cleanup() calls net_cleanup() which then calls
qemu_del_net_client() which would eventually call vhost_vdpa_cleanup()
again to free up the structures. This time, the loop in net_cleanup()
ensures that vhost_vdpa_cleanup() will be called one last time when
all the peer nics are detached and freed.

All unit tests pass with this change.

CC: imammedo@redhat.com
CC: jusual@redhat.com
CC: mst@redhat.com
Fixes: CVE-2023-3301
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2128929
Signed-off-by: Ani Sinha <anisinha@redhat.com>
Message-Id: <20230619065209.442185-1-anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
net/vhost-vdpa.c