File 54cb7f05-CVE-2013-6458.patch of Package libvirt.openSUSE_13.1_Update

commit 54cb7f05ec5c822bb786833367dc80327648f2c0
Author: Jiri Denemark <jdenemar@redhat.com>
Date:   Fri Dec 20 14:50:02 2013 +0100

    qemu: Avoid using stale data in virDomainGetBlockInfo
    
    CVE-2013-6458
    
    Generally, every API that is going to begin a job should do that before
    fetching data from vm->def. However, qemuDomainGetBlockInfo does not
    know whether it will have to start a job or not before checking vm->def.
    To avoid using disk alias that might have been freed while we were
    waiting for a job, we use its copy. In case the disk was removed in the
    meantime, we will fail with "cannot find statistics for device '...'"
    error message.
    
    (cherry picked from commit b799259583bd65c0b2f5042e6c3ff19637ade881)

Index: libvirt-1.1.2/src/qemu/qemu_driver.c
===================================================================
--- libvirt-1.1.2.orig/src/qemu/qemu_driver.c
+++ libvirt-1.1.2/src/qemu/qemu_driver.c
@@ -9706,10 +9706,12 @@ cleanup:
 }
 
 
-static int qemuDomainGetBlockInfo(virDomainPtr dom,
-                                  const char *path,
-                                  virDomainBlockInfoPtr info,
-                                  unsigned int flags) {
+static int
+qemuDomainGetBlockInfo(virDomainPtr dom,
+                       const char *path,
+                       virDomainBlockInfoPtr info,
+                       unsigned int flags)
+{
     virQEMUDriverPtr driver = dom->conn->privateData;
     virDomainObjPtr vm;
     int ret = -1;
@@ -9721,6 +9723,7 @@ static int qemuDomainGetBlockInfo(virDom
     int idx;
     int format;
     virQEMUDriverConfigPtr cfg = NULL;
+    char *alias = NULL;
 
     virCheckFlags(0, -1);
 
@@ -9827,13 +9830,16 @@ static int qemuDomainGetBlockInfo(virDom
         virDomainObjIsActive(vm)) {
         qemuDomainObjPrivatePtr priv = vm->privateData;
 
+        if (VIR_STRDUP(alias, disk->info.alias) < 0)
+            goto cleanup;
+
         if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
             goto cleanup;
 
         if (virDomainObjIsActive(vm)) {
             qemuDomainObjEnterMonitor(driver, vm);
             ret = qemuMonitorGetBlockExtent(priv->mon,
-                                            disk->info.alias,
+                                            alias,
                                             &info->allocation);
             qemuDomainObjExitMonitor(driver, vm);
         } else {
@@ -9847,6 +9853,7 @@ static int qemuDomainGetBlockInfo(virDom
     }
 
 cleanup:
+    VIR_FREE(alias);
     virStorageFileFreeMetadata(meta);
     VIR_FORCE_CLOSE(fd);
     if (vm)
openSUSE Build Service is sponsored by