Skip to contentSkip to conversation

validate the max-mem value

PATCH New Ky Srinivasan 1 participant 1 message Apr 14, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 validate the max-mem value

Currently, it is possible to set the mem-max value to value lower than 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. The patch is against changeSet 9618 (xen-3.0-testing)

Please apply to the 3.0.2 as well (This fixes a couple of bugs filed against SLES10).

Signed- off- by: [email protected]

common/dom0_ops.c +9 -2
diff -Nur xen/common/dom0_ops.c xen-new/common/dom0_ops.c
@@ -585,9 +585,16 @@
         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;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel