From: "Jan Beulich" Subject: [PATCH 2/4] x86: add address validity check to guest_map_l1e() Date: Thu, 10 Oct 2013 14:54:12 +0100 Message-ID: <5256CDA402000078000FA3E6@nat28.tlf.novell.com> References: <5256CC6F02000078000FA3D0@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part497A4094.0__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VUGgx-0002vo-0w for xen-devel@lists.xenproject.org; Thu, 10 Oct 2013 13:54:15 +0000 In-Reply-To: <5256CC6F02000078000FA3D0@nat28.tlf.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: xen-devel Cc: Keir Fraser 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. --=__Part497A4094.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Just like for guest_get_eff_l1e() this prevents accessing as page tables (and with the wrong memory attribute) internal data inside Xen happening to be mapped with 1Gb pages. Signed-off-by: Jan Beulich --- a/xen/include/asm-x86/paging.h +++ b/xen/include/asm-x86/paging.h @@ -360,7 +360,8 @@ guest_map_l1e(struct vcpu *v, unsigned l return paging_get_hostmode(v)->guest_map_l1e(v, addr, gl1mfn); =20 /* Find this l1e and its enclosing l1mfn in the linear map */ - if ( __copy_from_user(&l2e,=20 + if ( !__addr_ok(addr) || + __copy_from_user(&l2e, &__linear_l2_table[l2_linear_offset(addr)], sizeof(l2_pgentry_t)) !=3D 0 ) return NULL; --=__Part497A4094.0__= Content-Type: text/plain; name="x86-guest_map_l1e-check.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-guest_map_l1e-check.patch" x86: add address validity check to guest_map_l1e()=0A=0AJust like for = guest_get_eff_l1e() this prevents accessing as page=0Atables (and with the = wrong memory attribute) internal data inside Xen=0Ahappening to be mapped = with 1Gb pages.=0A=0ASigned-off-by: Jan Beulich =0A=0A--= - a/xen/include/asm-x86/paging.h=0A+++ b/xen/include/asm-x86/paging.h=0A@@ = -360,7 +360,8 @@ guest_map_l1e(struct vcpu *v, unsigned l=0A = return paging_get_hostmode(v)->guest_map_l1e(v, addr, gl1mfn);=0A =0A = /* Find this l1e and its enclosing l1mfn in the linear map */=0A- if ( = __copy_from_user(&l2e, =0A+ if ( !__addr_ok(addr) ||=0A+ = __copy_from_user(&l2e,=0A &__linear_l2_table[l2_l= inear_offset(addr)],=0A sizeof(l2_pgentry_t)) = !=3D 0 )=0A return NULL;=0A --=__Part497A4094.0__= 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 --=__Part497A4094.0__=--