[libvirt] [PATCH v2 1/2] esx: Do not crash SetAutoStart by double free

Marcos Paulo de Souza marcos.souza.org at gmail.com
Wed Aug 1 16:09:33 UTC 2018


SetAutoStart method cannot free virtualMachine using
esxVI_ObjectContent_Free, since:

esxVI_HostAutoStartManagerConfig_Free
 -> esxVI_AutoStartPowerInfo_Free
   -> esxVI_ManagedObjectReference_Free(item->key);

item->key, in this context, is virtualMachine->obj, so calling
esxVI_ObjectContent_Free creates a double free, becasuse
esxVI_ObjectContent_Free also calls esxVI_ManagedObjectReference_Free(&item->obj).

Removing the esxVI_ObjectContent_Free from SetAutoStart fixes this
problem.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
---
 src/esx/esx_driver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index cee98ebcaf..3835e4cb3c 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3421,7 +3421,9 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
         newPowerInfo->stopAction = NULL;
     }
 
-    esxVI_ObjectContent_Free(&virtualMachine);
+    /* HostAutoStartManagerConfig free method will call autoStartPowerInfoFree
+     * in order to free virtualMachine, since  newPowerInfo-> key points to
+     * virtualMachine */
     esxVI_HostAutoStartManagerConfig_Free(&spec);
     esxVI_AutoStartDefaults_Free(&defaults);
     esxVI_AutoStartPowerInfo_Free(&powerInfoList);
-- 
2.17.1




More information about the libvir-list mailing list