From: Ian Campbell Subject: Re: [PATCH 3/3] domctl: tighten XEN_DOMCTL_*_permission Date: Fri, 2 May 2014 09:19:26 +0100 Message-ID: <1399018766.29636.12.camel@kazak.uk.xensource.com> References: <536120AF020000780000DD1B@mail.emea.novell.com> <536123B8020000780000DD61@mail.emea.novell.com> <53613047.6070608@citrix.com> <53636A1C020000780000E560@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wg8gt-00068W-Ew for xen-devel@lists.xenproject.org; Fri, 02 May 2014 08:19:31 +0000 In-Reply-To: <53636A1C020000780000E560@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Keir Fraser , Andrew Cooper , Tim Deegan , xen-devel , Daniel De Graaf , Ian Jackson List-Id: xen-devel@lists.xenproject.org On Fri, 2014-05-02 at 08:49 +0100, Jan Beulich wrote: > >>> 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). AIUI that's pretty much how Daniel explained it to me as well. Ian.