From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] LZ4 : fix the data abort issue Date: Wed, 25 Mar 2015 16:32:51 +0000 Message-ID: <1427301171.10784.95.camel@citrix.com> References: <5512ECDC020000780006D8DB@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YaoLS-0006l6-Lv for xen-devel@lists.xenproject.org; Wed, 25 Mar 2015 16:39:54 +0000 In-Reply-To: <5512ECDC020000780006D8DB@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: tom.yeon@windriver.com, xen-devel , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org On Wed, 2015-03-25 at 16:14 +0000, Jan Beulich wrote: > If the part of the compression data are corrupted, or the compression > data is totally fake, the memory access over the limit is possible. > > This is the log from my system usning lz4 decompression. > [6502]data abort, halting > [6503]r0 0x00000000 r1 0x00000000 r2 0xdcea0ffc r3 0xdcea0ffc > [6509]r4 0xb9ab0bfd r5 0xdcea0ffc r6 0xdcea0ff8 r7 0xdce80000 > [6515]r8 0x00000000 r9 0x00000000 r10 0x00000000 r11 0xb9a98000 > [6522]r12 0xdcea1000 usp 0x00000000 ulr 0x00000000 pc 0x820149bc > [6528]spsr 0x400001f3 > and the memory addresses of some variables at the moment are > ref:0xdcea0ffc, op:0xdcea0ffc, oend:0xdcea1000 > > As you can see, COPYLENGH is 8bytes, so @ref and @op can access the momory > over @oend. > > Signed-off-by: JeHyeon Yeon > Reviewed-by: David Sterba > [Linux commit d5e7cafd69da24e6d6cc988fab6ea313a2577efc] > Signed-off-by: Jan Beulich Acked-by: Ian Campbell > > --- a/xen/common/lz4/decompress.c > +++ b/xen/common/lz4/decompress.c > @@ -132,6 +132,9 @@ static int INIT lz4_uncompress(const uns > /* Error: request to write beyond destination buffer */ > if (cpy > oend) > goto _output_error; > + if ((ref + COPYLENGTH) > oend || > + (op + COPYLENGTH) > oend) > + goto _output_error; > LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH)); > while (op < cpy) > *op++ = *ref++; > > >