From: "Jan Beulich" Subject: Re: [PATCH 3/3] domctl: tighten XEN_DOMCTL_*_permission Date: Fri, 02 May 2014 08:49:16 +0100 Message-ID: <53636A1C020000780000E560@mail.emea.novell.com> References: <536120AF020000780000DD1B@mail.emea.novell.com> <536123B8020000780000DD61@mail.emea.novell.com> <53613047.6070608@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wg8Dd-0004Z8-6K for xen-devel@lists.xenproject.org; Fri, 02 May 2014 07:49:17 +0000 In-Reply-To: <53613047.6070608@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Ian Campbell , xen-devel , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 30.04.14 at 19:17, wrote: > On 30/04/14 15:24, Jan Beulich wrote: >> --- a/xen/arch/x86/domctl.c >> +++ b/xen/arch/x86/domctl.c >> @@ -72,13 +72,11 @@ long arch_do_domctl( >> unsigned int np = domctl->u.ioport_permission.nr_ports; >> int allow = domctl->u.ioport_permission.allow_access; >> >> - ret = -EINVAL; >> - if ( (fp + np) > 65536 ) >> - break; >> - >> - if ( np == 0 ) >> - ret = 0; >> - else if ( xsm_ioport_permission(XSM_HOOK, d, fp, fp + np - 1, allow) > ) >> + if ( (fp + np - 1) < fp || (fp + np) > 0x10000 ) >> + ret = -EINVAL; >> + else if ( !ioports_access_permitted(current->domain, >> + fp, fp + np - 1) || >> + xsm_ioport_permission(XSM_HOOK, d, fp, fp + np - 1, allow) ) > > I don't see what the ioport permissions of the current domain have to do > with whether a domain is permitted to change the permissions for another > domain. > > I would expect that any domain builder domains would have no ioport > permissions at all, which would cause this hypercall to unconditionally > fail with -EPERM even if the domain builder domain is permitted to > assign ioport permissions to the domain it is building. My perspective is quite different - a building/controlling domain shouldn't be able to assign any resources it doesn't itself have control over. Which matches up with XEN_DOMCTL_{memory,ioport}_mapping, which too check requester permissions before doing the permission assignment (albeit there seems to be a tendency to agreement that the combination of permission granting and mapping is undesirable). Jan