From: Ian Campbell Subject: Re: [PATCH] lz4: check for underruns Date: Mon, 4 Aug 2014 11:50:50 +0100 Message-ID: <1407149450.32404.14.camel@kazak.uk.xensource.com> References: <53D634C2020000780002680D@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 1XEFrM-0005jH-DJ for xen-devel@lists.xenproject.org; Mon, 04 Aug 2014 10:51:20 +0000 In-Reply-To: <53D634C2020000780002680D@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: xen-devel , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org On Mon, 2014-07-28 at 10:32 +0100, Jan Beulich wrote: > While overruns are already being taken care of, underruns (resulting > from overflows in the respective "op + length" (or similar) operations > weren't. > > This is CVE-2014-4611. > > Signed-off-by: Jan Beulich > --- > Note that while a similar patch was proposed for Linux as replacement > for the three ones not really fixing the issue, there was no response > to them within over three weeks. Rather than continuing to wait in > order to not have our code needlessly diverge from the Linux original, > aim at fixing the issue in our tree now with the option of replacing > this fix with a Linux upstream blessed one later on. > > --- a/xen/common/lz4/decompress.c > +++ b/xen/common/lz4/decompress.c > @@ -84,6 +84,8 @@ static int INIT lz4_uncompress(const uns > ip += length; > break; /* EOF */ > } > + if (unlikely((unsigned long)cpy < (unsigned long)op)) > + goto _output_error; > LZ4_WILDCOPY(ip, op, cpy); > ip -= (op - cpy); > op = cpy; > @@ -142,6 +144,8 @@ static int INIT lz4_uncompress(const uns > goto _output_error; > continue; > } > + if (unlikely((unsigned long)cpy < (unsigned long)op)) > + goto _output_error; > LZ4_SECURECOPY(ref, op, cpy); SECURE_COPY already includes the check but without the error handling bit, just continuing under those circumstances is a bit odd, but your change isn't incorrect because of it. Acked-by: Ian Campbell