From: kaf24@firebug.cl.cam.ac.uk Date: Sat, 15 Apr 2006 08:52:32 +0000 (+0100) Subject: Fix SETMAXMEM dom0_op with proper locking. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16158^2~2^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=660442fdafa7c0d0b145c0ae372aa3e93c7322eb;p=xen.git Fix SETMAXMEM dom0_op with proper locking. Signed-off-by: Keir Fraser --- diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index 3c5358663b..cba0117fae 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -581,27 +581,31 @@ long do_dom0_op(GUEST_HANDLE(dom0_op_t) u_dom0_op) case DOM0_SETDOMAINMAXMEM: { struct domain *d; + unsigned long new_max; + ret = -ESRCH; d = find_domain_by_id(op->u.setdomainmaxmem.domain); - if ( d != NULL ) + if ( d == NULL ) + break; + + ret = -EINVAL; + new_max = op->u.setdomainmaxmem.max_memkb >> (PAGE_SHIFT-10); + + spin_lock(&d->page_alloc_lock); + if ( new_max >= d->tot_pages ) { - 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); + d->max_pages = new_max; + ret = 0; } + spin_unlock(&d->page_alloc_lock); + + put_domain(d); } break; case DOM0_SETDOMAINHANDLE: { - struct domain *d; + struct domain *d; ret = -ESRCH; d = find_domain_by_id(op->u.setdomainhandle.domain); if ( d != NULL )