diff mbox

[07/10] vl.c: numa_add_node(): Validate nodeid before using it

Message ID 1357928108-21066-8-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Jan. 11, 2013, 6:15 p.m. UTC
Without this check, qemu-kvm will corrupt memory if a too-large nodeid
is provided in the command-line. e.g.:

  -numa node,mem=...,cpus=...,nodeid=65

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 vl.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/vl.c b/vl.c
index 19010fa..31175f6 100644
--- a/vl.c
+++ b/vl.c
@@ -1112,6 +1112,11 @@  static void numa_node_add(const char *optarg)
         nodenr = strtoull(option, NULL, 10);
     }
 
+    if (nodenr >= MAX_NODES) {
+        fprintf(stderr, "qemu: invalid NUMA nodeid: %d\n", nodenr);
+        exit(1);
+    }
+
     if (get_param_value(option, 128, "mem", optarg) == 0) {
         node_mem[nodenr] = 0;
     } else {