Skip to contentSkip to conversation

migration: Assign current_migration as NULL after migration

PATCH In review Keqian Zhu 1 participant 2 messages Jun 28, 2020 – Jul 1, 2020

lore
Share & tools
lore

Keqian Zhu

author
#0 lore raw

PATCH 1/1 migration: Assign current_migration as NULL after migration

In migration_shutdown, global var current_migration is freed but not assigned to NULL, which may cause heap-use-after-free problem if the following code logic is abnormal.

---
 migration/migration.c | 1 +
 1 file changed, 1 insertion(+)
migration/migration.c +1 -0
index 481a590f72..effffd7332 100644
@@ -189,6 +189,7 @@ void migration_shutdown(void)
      */
     migrate_fd_cancel(current_migration);
     object_unref(OBJECT(current_migration));
+    current_migration = NULL;
 }
 
 /* For outgoing */
Signature · 1 line
2.19.1
author
#1 lore raw

Please ignore this patch :-)

If we shutdown VM during migration, the migration thread may still ref current_migration at this point.

Quoted 22 lines · Keqian Zhu

In migration_shutdown, global var current_migration is freed but not assigned to NULL, which may cause heap-use-after-free problem if the following code logic is abnormal.

---
 migration/migration.c | 1 +
 1 file changed, 1 insertion(+)
migration/migration.c +1 -0
index 481a590f72..effffd7332 100644
@@ -189,6 +189,7 @@ void migration_shutdown(void)
      */
     migrate_fd_cancel(current_migration);
     object_unref(OBJECT(current_migration));
+    current_migration = NULL;
 }
 
 /* For outgoing */