]> xenbits.xensource.com Git - xen.git/commitdiff
Currently, it is possible to set the mem-max value to value lower than
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 15 Apr 2006 08:47:55 +0000 (09:47 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 15 Apr 2006 08:47:55 +0000 (09:47 +0100)
what has been currently allocated to the domain causing the kernel to
crash. This patch validates the value passed in and prevents setting the
value below the current allocation level.

Signed-off-by: ksrinivasan@novell.com
xen/common/dom0_ops.c

index 74b2d660f588f05ab526a30a8c72307c497f1f7e..3c5358663b9f7f307a7c8478323a72c25d8d8500 100644 (file)
@@ -585,9 +585,16 @@ long do_dom0_op(GUEST_HANDLE(dom0_op_t) u_dom0_op)
         d = find_domain_by_id(op->u.setdomainmaxmem.domain);
         if ( d != NULL )
         {
-            d->max_pages = op->u.setdomainmaxmem.max_memkb >> (PAGE_SHIFT-10);
+            unsigned long new_max;
+            new_max = op->u.setdomainmaxmem.max_memkb >> (PAGE_SHIFT-10);
+            if (new_max < d->tot_pages) 
+                ret = -EINVAL;
+            else 
+            {  
+                d->max_pages = new_max;
+                ret = 0;
+            }
             put_domain(d);
-            ret = 0;
         }
     }
     break;