From: "Jan Beulich" Subject: [PATCH] x86/mm: fix checks against max_mapped_pfn Date: Thu, 03 Apr 2014 08:47:28 +0100 Message-ID: <533D2E300200007800005019@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part14267700.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WVcN2-0007jI-En for xen-devel@lists.xenproject.org; Thu, 03 Apr 2014 07:47:32 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Tim Deegan , Andres Lagar-Cavilla List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part14267700.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This value is an inclusive one, i.e. this fixes an off-by-one in memory sharing and an off-by-two in shadow code. Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1267,8 +1267,8 @@ int relinquish_shared_pages(struct domai return 0; =20 p2m_lock(p2m); - for (gfn =3D p2m->next_shared_gfn_to_relinquish;=20 - gfn < p2m->max_mapped_pfn; gfn++ ) + for ( gfn =3D p2m->next_shared_gfn_to_relinquish; + gfn <=3D p2m->max_mapped_pfn; gfn++ ) { p2m_access_t a; p2m_type_t t; --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -3487,9 +3487,7 @@ int shadow_track_dirty_vram(struct domai struct sh_dirty_vram *dirty_vram =3D d->arch.hvm_domain.dirty_vram; struct p2m_domain *p2m =3D p2m_get_hostp2m(d); =20 - if (end_pfn < begin_pfn - || begin_pfn > p2m->max_mapped_pfn - || end_pfn >=3D p2m->max_mapped_pfn) + if ( end_pfn < begin_pfn || end_pfn > p2m->max_mapped_pfn + 1 ) return -EINVAL; =20 /* We perform p2m lookups, so lock the p2m upfront to avoid deadlock = */ --=__Part14267700.1__= Content-Type: text/plain; name="x86-max-mapped-pfn-checks.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-max-mapped-pfn-checks.patch" x86/mm: fix checks against max_mapped_pfn=0A=0AThis value is an inclusive = one, i.e. this fixes an off-by-one in memory=0Asharing and an off-by-two = in shadow code.=0A=0ASigned-off-by: Jan Beulich =0A=0A--= - a/xen/arch/x86/mm/mem_sharing.c=0A+++ b/xen/arch/x86/mm/mem_sharing.c=0A@= @ -1267,8 +1267,8 @@ int relinquish_shared_pages(struct domai=0A = return 0;=0A =0A p2m_lock(p2m);=0A- for (gfn =3D p2m->next_shared_gf= n_to_relinquish; =0A- gfn < p2m->max_mapped_pfn; gfn++ )=0A+ = for ( gfn =3D p2m->next_shared_gfn_to_relinquish;=0A+ gfn <=3D = p2m->max_mapped_pfn; gfn++ )=0A {=0A p2m_access_t a;=0A = p2m_type_t t;=0A--- a/xen/arch/x86/mm/shadow/common.c=0A+++ b/xen/arch/x86= /mm/shadow/common.c=0A@@ -3487,9 +3487,7 @@ int shadow_track_dirty_vram(str= uct domai=0A struct sh_dirty_vram *dirty_vram =3D d->arch.hvm_domain.di= rty_vram;=0A struct p2m_domain *p2m =3D p2m_get_hostp2m(d);=0A =0A- = if (end_pfn < begin_pfn=0A- || begin_pfn > p2m->max_mapped_pfn= =0A- || end_pfn >=3D p2m->max_mapped_pfn)=0A+ if ( end_pfn < = begin_pfn || end_pfn > p2m->max_mapped_pfn + 1 )=0A return = -EINVAL;=0A =0A /* We perform p2m lookups, so lock the p2m upfront to = avoid deadlock */=0A --=__Part14267700.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part14267700.1__=--