From: "Jan Beulich" Subject: [PATCH] LZ4 : fix the data abort issue Date: Wed, 25 Mar 2015 16:14:04 +0000 Message-ID: <5512ECDC020000780006D8DB@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part2D1967DC.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YanwW-0002Pv-7A for xen-devel@lists.xenproject.org; Wed, 25 Mar 2015 16:14:08 +0000 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: Ian Campbell , tom.yeon@windriver.com, Keir Fraser , Ian Jackson , 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. --=__Part2D1967DC.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- 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++ =3D *ref++; --=__Part2D1967DC.1__= Content-Type: text/plain; name="lz4-fix-overrun.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="lz4-fix-overrun.patch" LZ4 : fix the data abort issue=0A=0AIf the part of the compression data = are corrupted, or the compression=0Adata is totally fake, the memory = access over the limit is possible.=0A=0AThis is the log from my system = usning lz4 decompression.=0A [6502]data abort, halting=0A [6503]r0 = 0x00000000 r1 0x00000000 r2 0xdcea0ffc r3 0xdcea0ffc=0A [6509]r4 = 0xb9ab0bfd r5 0xdcea0ffc r6 0xdcea0ff8 r7 0xdce80000=0A [6515]r8 = 0x00000000 r9 0x00000000 r10 0x00000000 r11 0xb9a98000=0A [6522]r12 = 0xdcea1000 usp 0x00000000 ulr 0x00000000 pc 0x820149bc=0A [6528]spsr = 0x400001f3=0Aand the memory addresses of some variables at the moment = are=0A ref:0xdcea0ffc, op:0xdcea0ffc, oend:0xdcea1000=0A=0AAs you can = see, COPYLENGH is 8bytes, so @ref and @op can access the momory=0Aover = @oend.=0A=0ASigned-off-by: JeHyeon Yeon =0AReviewed= -by: David Sterba =0A[Linux commit d5e7cafd69da24e6d6cc988= fab6ea313a2577efc]=0ASigned-off-by: Jan Beulich =0A=0A--= - a/xen/common/lz4/decompress.c=0A+++ b/xen/common/lz4/decompress.c=0A@@ = -132,6 +132,9 @@ static int INIT lz4_uncompress(const uns=0A = /* Error: request to write beyond destination buffer */=0A = if (cpy > oend)=0A goto _output_error;=0A+ = if ((ref + COPYLENGTH) > oend ||=0A+ = (op + COPYLENGTH) > oend)=0A+ goto _output_error;= =0A LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));=0A = while (op < cpy)=0A *op++ =3D = *ref++;=0A --=__Part2D1967DC.1__= 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 --=__Part2D1967DC.1__=--