From: "Jan Beulich" Subject: Re: [PATCH v2 2/4] xen: introduce grant_map_exists Date: Mon, 06 Oct 2014 09:22:08 +0100 Message-ID: <54326D50020000780003C589@mail.emea.novell.com> References: <1412347845-27755-2-git-send-email-stefano.stabellini@eu.citrix.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 1Xb3Yb-0003fV-E3 for xen-devel@lists.xenproject.org; Mon, 06 Oct 2014 08:22:13 +0000 In-Reply-To: <1412347845-27755-2-git-send-email-stefano.stabellini@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: Stefano Stabellini Cc: julien.grall@citrix.com, xen-devel , Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org >>> On 03.10.14 at 16:50, wrote: > --- a/xen/common/grant_table.c > +++ b/xen/common/grant_table.c > @@ -484,6 +484,36 @@ static int _set_status(unsigned gt_version, > return _set_status_v2(domid, readonly, mapflag, shah, act, status); > } > > +static bool_t grant_map_exists(struct domain *ld, > + struct grant_table *rgt, Please constify these if possible. > + unsigned long mfn) > +{ > + struct active_grant_entry *act; And this one too. > + grant_ref_t ref; > + bool_t ret = 0; > + > + ASSERT(&rgt->lock); > + > + for ( ref = 0; ref != nr_grant_entries(rgt); ref++ ) This loop's worst case iteration count is controlled solely by the "gnttab_max_nr_frames=" command line option afaict, i.e. for a large enough specified value this is going to become a security issue. > + { > + act = &active_entry(rgt, ref); > + > + if ( !act->pin ) > + continue; > + > + if ( act->domid != ld->domain_id ) > + continue; > + > + if ( act->frame != mfn ) > + continue; > + > + ret = 1; > + break; > + } > + > + return ret; > +} Apart from it not being very useful to introduce a static function without consumer, I very much expect this patch on its own to also cause a build error (unused static function). Please fold this into the patch adding a consumer of the function. Jan