]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainDefParseXML: Check for malicious cpu ids in <numa/>
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 7 Aug 2015 14:36:38 +0000 (16:36 +0200)
committerCole Robinson <crobinso@redhat.com>
Tue, 22 Sep 2015 00:17:58 +0000 (20:17 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1176020

Some users think this is a good idea:

      <vcpu placement='static'>4</vcpu>
      <cpu mode='host-model'>
        <model fallback='allow'/>
        <numa>
          <cell id='0' cpus='0-1' memory='1048576' unit='KiB'/>
          <cell id='1' cpus='9-10' memory='2097152' unit='KiB'/>
        </numa>
      </cpu>

It's not. Lets therefore introduce a check and discourage them in
doing so.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 82af954c527e88111b05d50953b80eb4afde4d9a)

src/conf/domain_conf.c

index 6b557d14813e5f9a481b80914385a0d980fba5ef..0ce41884bcab32ea5925b37a73c3b4e4f11742fe 100644 (file)
@@ -15070,6 +15070,12 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto error;
     }
 
+    if (virDomainNumaGetMaxCPUID(def->numa) >= def->maxvcpus) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("CPU IDs in <numa> exceed the <vcpu> count"));
+        goto error;
+    }
+
     if (virDomainNumatuneParseXML(def->numa,
                                   def->placement_mode ==
                                   VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,