From: "Jan Beulich" Subject: [PATCH] lz4: check for underruns Date: Mon, 28 Jul 2014 10:32:18 +0100 Message-ID: <53D634C2020000780002680D@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part4775CFB2.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XBhI5-0006kF-BM for xen-devel@lists.xenproject.org; Mon, 28 Jul 2014 09:32:21 +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 , 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. --=__Part4775CFB2.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 +=3D length; break; /* EOF */ } + if (unlikely((unsigned long)cpy < (unsigned long)op)) + goto _output_error; LZ4_WILDCOPY(ip, op, cpy); ip -=3D (op - cpy); op =3D 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); op =3D cpy; /* correction */ } @@ -207,6 +211,8 @@ static int lz4_uncompress_unknownoutputs op +=3D length; break;/* Necessarily EOF, due to parsing restrictio= ns */ } + if (unlikely((unsigned long)cpy < (unsigned long)op)) + goto _output_error; LZ4_WILDCOPY(ip, op, cpy); ip -=3D (op - cpy); op =3D cpy; @@ -270,6 +276,8 @@ static int lz4_uncompress_unknownoutputs goto _output_error; continue; } + if (unlikely((unsigned long)cpy < (unsigned long)op)) + goto _output_error; LZ4_SECURECOPY(ref, op, cpy); op =3D cpy; /* correction */ } --=__Part4775CFB2.1__= Content-Type: text/plain; name="lz4-check-underruns.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="lz4-check-underruns.patch" lz4: check for underruns=0A=0AWhile overruns are already being taken care = of, underruns (resulting=0Afrom overflows in the respective "op + length" = (or similar) operations=0Aweren't.=0A=0AThis is CVE-2014-4611.=0A=0ASigned-= off-by: Jan Beulich =0A---=0ANote that while a similar = patch was proposed for Linux as replacement=0Afor the three ones not = really fixing the issue, there was no response=0Ato them within over three = weeks. Rather than continuing to wait in=0Aorder to not have our code = needlessly diverge from the Linux original,=0Aaim at fixing the issue in = our tree now with the option of replacing=0Athis fix with a Linux upstream = blessed one later on.=0A=0A--- a/xen/common/lz4/decompress.c=0A+++ = b/xen/common/lz4/decompress.c=0A@@ -84,6 +84,8 @@ static int INIT = lz4_uncompress(const uns=0A ip +=3D length;=0A = break; /* EOF */=0A }=0A+ if (unlikely((unsig= ned long)cpy < (unsigned long)op))=0A+ goto _output_error;= =0A LZ4_WILDCOPY(ip, op, cpy);=0A ip -=3D (op - = cpy);=0A op =3D cpy;=0A@@ -142,6 +144,8 @@ static int INIT = lz4_uncompress(const uns=0A goto _output_error;= =0A continue;=0A }=0A+ if = (unlikely((unsigned long)cpy < (unsigned long)op))=0A+ = goto _output_error;=0A LZ4_SECURECOPY(ref, op, cpy);=0A = op =3D cpy; /* correction */=0A }=0A@@ -207,6 +211,8 @@ static int = lz4_uncompress_unknownoutputs=0A op +=3D length;=0A = break;/* Necessarily EOF, due to parsing restrictio= ns */=0A }=0A+ if (unlikely((unsigned long)cpy < = (unsigned long)op))=0A+ goto _output_error;=0A = LZ4_WILDCOPY(ip, op, cpy);=0A ip -=3D (op - cpy);=0A op = =3D cpy;=0A@@ -270,6 +276,8 @@ static int lz4_uncompress_unknownoutputs=0A = goto _output_error;=0A = continue;=0A }=0A+ if (unlikely((unsigned long)cpy < = (unsigned long)op))=0A+ goto _output_error;=0A = LZ4_SECURECOPY(ref, op, cpy);=0A op =3D cpy; /* correction = */=0A }=0A --=__Part4775CFB2.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 --=__Part4775CFB2.1__=--