From: "Jan Beulich" Subject: [PATCH] domctl: don't allow certain operations on Dom0 Date: Fri, 19 Sep 2008 14:06:33 +0100 Message-ID: <48D3BFF9.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org XEN_DOMCTL_setvcpucontext, XEN_DOMCTL_max_vcpus, and XEN_DOMCTL_setdebugging don't seem to allow Dom0 as the subject domain (based on the criteria that they pause that domain in order to do their job). Apart from this, I wonder about the usefulness of XEN_DOMCTL_max_vcpus on a domain that was already booted - generally, I would expect OSes to be allowed to assume they know how many CPUs they might ever run on (at least Linux indeed does, by requiring that cpu_possible_map never changes). Signed-off-by: Jan Beulich Index: 2008-09-19/xen/common/domctl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-09-19.orig/xen/common/domctl.c 2008-09-19 13:36:28.000000000 = +0200 +++ 2008-09-19/xen/common/domctl.c 2008-09-19 13:36:52.000000000 = +0200 @@ -223,7 +223,8 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc goto svc_out; =20 ret =3D -EINVAL; - if ( (vcpu >=3D MAX_VIRT_CPUS) || ((v =3D d->vcpu[vcpu]) =3D=3D = NULL) ) + if ( d =3D=3D current->domain || + (vcpu >=3D MAX_VIRT_CPUS) || ((v =3D d->vcpu[vcpu]) =3D=3D = NULL) ) goto svc_out; =20 if ( guest_handle_is_null(op->u.vcpucontext.ctxt) ) @@ -392,14 +393,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc struct domain *d; unsigned int i, max =3D op->u.max_vcpus.max, cpu; =20 - ret =3D -EINVAL; - if ( max > MAX_VIRT_CPUS ) - break; - ret =3D -ESRCH; if ( (d =3D rcu_lock_domain_by_id(op->domain)) =3D=3D NULL ) break; =20 + ret =3D -EINVAL; + if ( d =3D=3D current->domain || max > MAX_VIRT_CPUS ) + break; + ret =3D xsm_max_vcpus(d); if ( ret ) { @@ -706,6 +707,10 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc if ( d =3D=3D NULL ) break; =20 + ret =3D -EINVAL; + if ( d =3D=3D current->domain ) + break; + ret =3D xsm_setdebugging(d); if ( ret ) {