]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix leak of allocated security label
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 13 Jan 2010 15:30:24 +0000 (15:30 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 21 Jan 2010 14:00:16 +0000 (14:00 +0000)
If a VM fails to start, we can't simply free the security label
strings, we must call the domainReleaseSecurityLabel() method
otherwise the reserved 'mcs' level will be leaked in SElinux

* src/qemu/qemu_driver.c: Invoke domainReleaseSecurityLabel()
  when domain fails to start

src/qemu/qemu_driver.c

index ad2737a5a23b4769cc8b09b67e4c2da3e348afe3..6672eae8d377cff199b643f7d285bbd746f40089 100644 (file)
@@ -2985,11 +2985,9 @@ cleanup:
     /* We jump here if we failed to start the VM for any reason
      * XXX investigate if we can kill this block and safely call
      * qemudShutdownVMDaemon even though no PID is running */
-    if (vm->def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
-        VIR_FREE(vm->def->seclabel.model);
-        VIR_FREE(vm->def->seclabel.label);
-        VIR_FREE(vm->def->seclabel.imagelabel);
-    }
+    if (driver->securityDriver &&
+        driver->securityDriver->domainReleaseSecurityLabel)
+        driver->securityDriver->domainReleaseSecurityLabel(conn, vm);
     qemuRemoveCgroup(conn, driver, vm, 0);
     if ((vm->def->ngraphics == 1) &&
         vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&