[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.10 01/33] migration: Fix use-after-free of migration state o
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.10 01/33] migration: Fix use-after-free of migration state object |
Date: |
Thu, 22 Feb 2024 00:46:44 +0300 |
From: Fabiano Rosas <farosas@suse.de>
We're currently allowing the process_incoming_migration_bh bottom-half
to run without holding a reference to the 'current_migration' object,
which leads to a segmentation fault if the BH is still live after
migration_shutdown() has dropped the last reference to
current_migration.
In my system the bug manifests as migrate_multifd() returning true
when it shouldn't and multifd_load_shutdown() calling
multifd_recv_terminate_threads() which crashes due to an uninitialized
multifd_recv_state.
Fix the issue by holding a reference to the object when scheduling the
BH and dropping it before returning from the BH. The same is already
done for the cleanup_bh at migrate_fd_cleanup_schedule().
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1969
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240119233922.32588-2-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
(cherry picked from commit 27eb8499edb2bc952c29ddae0bdac9fc959bf7b1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/migration/migration.c b/migration/migration.c
index c8ca7927b4..9b496cce1d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -572,6 +572,7 @@ static void process_incoming_migration_bh(void *opaque)
MIGRATION_STATUS_COMPLETED);
qemu_bh_delete(mis->bh);
migration_incoming_state_destroy();
+ object_unref(OBJECT(migrate_get_current()));
}
static void coroutine_fn
@@ -638,6 +639,7 @@ process_incoming_migration_co(void *opaque)
goto fail;
}
mis->bh = qemu_bh_new(process_incoming_migration_bh, mis);
+ object_ref(OBJECT(migrate_get_current()));
qemu_bh_schedule(mis->bh);
mis->migration_incoming_co = NULL;
return;
--
2.39.2
- [Stable-7.2.10 v0 00/33] Patch Round-up for stable 7.2.10, freeze on 2024-03-02, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 01/33] migration: Fix use-after-free of migration state object,
Michael Tokarev <=
- [Stable-7.2.10 02/33] qemu-docs: Update options for graphical frontends, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 03/33] block/blkio: Make s->mem_region_alignment be 64 bits, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 04/33] target/arm: fix exception syndrome for AArch32 bkpt insn, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 05/33] system/vl.c: Fix handling of '-serial none -serial something', Michael Tokarev, 2024/02/21
- [Stable-7.2.10 06/33] qemu-options.hx: Improve -serial option documentation, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 07/33] pci-host: designware: Limit value range of iATU viewport register, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 08/33] hw/smbios: Fix OEM strings table option validation, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 09/33] hw/smbios: Fix port connector option validation, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 11/33] cxl/cdat: Handle cdat table build errors, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 10/33] vhost-user.rst: Fix vring address description, Michael Tokarev, 2024/02/21