From: Tim Deegan Subject: Re: [PATCH 3/3] domctl: tighten XEN_DOMCTL_*_permission Date: Thu, 1 May 2014 17:37:09 +0200 Message-ID: <20140501153709.GH86038@deinos.phlegethon.org> References: <536120AF020000780000DD1B@mail.emea.novell.com> <536123B8020000780000DD61@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wft2t-0004N3-Si for xen-devel@lists.xenproject.org; Thu, 01 May 2014 15:37:11 +0000 Content-Disposition: inline In-Reply-To: <536123B8020000780000DD61@mail.emea.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: Jan Beulich Cc: Ian Campbell , xen-devel , Keir Fraser , Ian Jackson List-Id: xen-devel@lists.xenproject.org At 15:24 +0100 on 30 Apr (1398867864), Jan Beulich wrote: > @@ -72,13 +72,11 @@ long arch_do_domctl( > unsigned int np = domctl->u.ioport_permission.nr_ports; > int allow = domctl->u.ioport_permission.allow_access; > > - ret = -EINVAL; > - if ( (fp + np) > 65536 ) > - break; > - > - if ( np == 0 ) > - ret = 0; > - else if ( xsm_ioport_permission(XSM_HOOK, d, fp, fp + np - 1, allow) ) > + if ( (fp + np - 1) < fp || (fp + np) > 0x10000 ) > + ret = -EINVAL; I think this fails if (fp + np) overflows exactly to 0. How about 'if ( (fp + np) <= fp || (fp + np) > 0x10000 )' ? Tim.