From: Tim Deegan Subject: Re: [PATCH] xen/arm: add_to_physmap_one: Avoid to map mfn 0 if an error occurs Date: Thu, 24 Oct 2013 10:11:25 +0200 Message-ID: <20131024081125.GA87823@deinos.phlegethon.org> References: <1382545727-6595-1-git-send-email-julien.grall@linaro.org> 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 1VZG10-0007Rl-G2 for xen-devel@lists.xenproject.org; Thu, 24 Oct 2013 08:11:34 +0000 Content-Disposition: inline In-Reply-To: <1382545727-6595-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: xen-devel@lists.xenproject.org, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org List-Id: xen-devel@lists.xenproject.org At 17:28 +0100 on 23 Oct (1382545727), Julien Grall wrote: > By default, the function add_to_physmap_one set mfn to 0. Some code paths that > result to an error, continue and the map the mfn 0 (valid on ARM) to the > slot given by the guest. > > To fix the problem, return directly an error if sanity check has failed. > > Signed-off-by: Julien Grall Acked-by: Tim Deegan > --- > xen/arch/arm/mm.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c > index 474dfef..eaeb0c3 100644 > --- a/xen/arch/arm/mm.c > +++ b/xen/arch/arm/mm.c > @@ -981,6 +981,8 @@ static int xenmem_add_to_physmap_one( > idx &= ~XENMAPIDX_grant_table_status; > if ( idx < nr_status_frames(d->grant_table) ) > mfn = virt_to_mfn(d->grant_table->status[idx]); > + else > + return -EINVAL; > } > else > { > @@ -990,6 +992,8 @@ static int xenmem_add_to_physmap_one( > > if ( idx < nr_grant_frames(d->grant_table) ) > mfn = virt_to_mfn(d->grant_table->shared_raw[idx]); > + else > + return -EINVAL; > } > > d->arch.grant_table_gpfn[idx] = gpfn; > @@ -999,6 +1003,8 @@ static int xenmem_add_to_physmap_one( > case XENMAPSPACE_shared_info: > if ( idx == 0 ) > mfn = virt_to_mfn(d->shared_info); > + else > + return -EINVAL; > break; > case XENMAPSPACE_gmfn_foreign: > { > -- > 1.8.3.1 >