From: "Jan Beulich" Subject: [PATCH v4 1/2] x86/hvm: fix segment validation Date: Fri, 22 Nov 2013 14:20:44 +0000 Message-ID: <528F764C0200007800105E41@nat28.tlf.novell.com> References: <528DF45E.7050905@citrix.com> <20131121150355.GC89770@deinos.phlegethon.org> <528E219B.6060801@citrix.com> <20131121151308.GD89770@deinos.phlegethon.org> <20131121153231.GE89770@deinos.phlegethon.org> <528E5753.5020104@citrix.com> <528F53250200007800105C7C@nat28.tlf.novell.com> <20131122115453.GB86420@deinos.phlegethon.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF1C2212C.2__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VjrbC-00061f-Qg for xen-devel@lists.xenproject.org; Fri, 22 Nov 2013 14:20:47 +0000 In-Reply-To: <20131122115453.GB86420@deinos.phlegethon.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: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , keir@xen.org, David Binderman , Tim Deegan 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. --=__PartF1C2212C.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Also Coverity CID 1055180. =20 Reported-by: David Binderman Signed-off-by: Tim Deegan Use _SEGMENT_* instead of plain numbers and adjust a comment. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2280,7 +2280,7 @@ static int hvm_load_segment_selector( if ( !(desc.b & (1u<<11)) ) goto unmap_and_fail; /* Non-conforming segment: check DPL against RPL. */ - if ( ((desc.b & (6u<<9)) !=3D 6) && (dpl !=3D rpl) ) + if ( !(desc.b & _SEGMENT_EC) && (dpl !=3D rpl) ) goto unmap_and_fail; break; case x86_seg_ss: @@ -2299,8 +2299,13 @@ static int hvm_load_segment_selector( /* Readable code or data segment? */ if ( (desc.b & (5u<<9)) =3D=3D (4u<<9) ) goto unmap_and_fail; - /* Non-conforming segment: check DPL against RPL and CPL. */ - if ( ((desc.b & (6u<<9)) !=3D 6) && ((dpl < cpl) || (dpl < = rpl)) ) + /* + * Data or non-conforming code segment: + * check DPL against RPL and CPL. + */ + if ( ((desc.b & (_SEGMENT_EC|_SEGMENT_CODE)) !=3D + (_SEGMENT_EC|_SEGMENT_CODE)) + && ((dpl < cpl) || (dpl < rpl)) ) goto unmap_and_fail; break; } --=__PartF1C2212C.2__= Content-Type: text/plain; name="x86-HVM-segment-validation.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-HVM-segment-validation.patch" x86/hvm: fix segment validation=0A =0AAlso Coverity CID 1055180.=0A = =0AReported-by: David Binderman =0ASigned-off-by: Tim = Deegan =0A=0AUse _SEGMENT_* instead of plain numbers and = adjust a comment.=0A=0ASigned-off-by: Jan Beulich =0A=0A= --- a/xen/arch/x86/hvm/hvm.c=0A+++ b/xen/arch/x86/hvm/hvm.c=0A@@ -2280,7 = +2280,7 @@ static int hvm_load_segment_selector(=0A if ( = !(desc.b & (1u<<11)) )=0A goto unmap_and_fail;=0A = /* Non-conforming segment: check DPL against RPL. */=0A- if = ( ((desc.b & (6u<<9)) !=3D 6) && (dpl !=3D rpl) )=0A+ if ( = !(desc.b & _SEGMENT_EC) && (dpl !=3D rpl) )=0A goto = unmap_and_fail;=0A break;=0A case x86_seg_ss:=0A@@ = -2299,8 +2299,13 @@ static int hvm_load_segment_selector(=0A = /* Readable code or data segment? */=0A if ( (desc.b & = (5u<<9)) =3D=3D (4u<<9) )=0A goto unmap_and_fail;=0A- = /* Non-conforming segment: check DPL against RPL and CPL. */=0A- = if ( ((desc.b & (6u<<9)) !=3D 6) && ((dpl < cpl) || (dpl < rpl)) = )=0A+ /*=0A+ * Data or non-conforming code = segment:=0A+ * check DPL against RPL and CPL.=0A+ = */=0A+ if ( ((desc.b & (_SEGMENT_EC|_SEGMENT_CODE)) !=3D=0A+ = (_SEGMENT_EC|_SEGMENT_CODE))=0A+ && ((dpl < = cpl) || (dpl < rpl)) )=0A goto unmap_and_fail;=0A = break;=0A }=0A --=__PartF1C2212C.2__= 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 --=__PartF1C2212C.2__=--