From: "Jan Beulich" Subject: Re: [PATCH] domctl: fix IRQ permission granting/revocation Date: Thu, 11 Dec 2014 11:44:34 +0000 Message-ID: <548991B2020000780004EE44@mail.emea.novell.com> References: <54880D6B020000780004E6AA@mail.emea.novell.com> <1418205196.19809.34.camel@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xz2Ag-0007iD-62 for xen-devel@lists.xenproject.org; Thu, 11 Dec 2014 11:44:38 +0000 In-Reply-To: <1418205196.19809.34.camel@eu.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: Ian Campbell , dgdegra@tycho.nsa.gov Cc: xen-devel , Tim Deegan , Keir Fraser , Ian Jackson List-Id: xen-devel@lists.xenproject.org >>> On 10.12.14 at 10:53, wrote: > On Wed, 2014-12-10 at 08:07 +0000, Jan Beulich wrote: >> --- a/xen/common/domctl.c >> +++ b/xen/common/domctl.c >> @@ -981,18 +981,18 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe >> >> case XEN_DOMCTL_irq_permission: >> { >> - unsigned int pirq = op->u.irq_permission.pirq; >> + unsigned int pirq = op->u.irq_permission.pirq, irq; >> int allow = op->u.irq_permission.allow_access; >> >> if ( pirq >= d->nr_pirqs ) >> ret = -EINVAL; >> - else if ( !pirq_access_permitted(current->domain, pirq) || >> + else if ( !(irq = pirq_access_permitted(current->domain, pirq)) || > > I find hiding an assignment inside the second condition in a chain of > if's to be rather obfuscated. Doing an assignment in a standalone if > statement is one thing, this is going to far IMHO. Changed. My main intention was to avoid having to add another "break;". > Also, you range check pirq against d->nr_pirqs but then translate it > against current->domain, is that correct? No, it's not. As much as xsm_irq_permission(XSM_HOOK, d, pirq, allow) is bogus, yet it's not clear to me whether switching that to use the Xen IRQ number is okay without any other changes. Daniel? Jan