From: "Jan Beulich" <JBeulich@suse.com>
To: "Greg KH" <gregkh@linuxfoundation.org>,
"Don A. Bailey" <donb@securitymouse.com>
Cc: <linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH] lz4: add overrun checks to lz4_uncompress_unknownoutputsize()
Date: Fri, 04 Jul 2014 14:01:43 +0100 [thread overview]
Message-ID: <53B6C1D70200007800020BE7@mail.emea.novell.com> (raw)
In-Reply-To:
>>> On 04.07.14 at 08:12, Jan Beulich wrote:
>>>> On 04.07.14 at 01:11, <gregkh@linuxfoundation.org> wrote:
> > From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >
> > Jan points out that I forgot to make the needed fixes to the
> > lz4_uncompress_unknownoutputsize() function to mirror the changes done
> > in lz4_decompress() with regards to potential pointer overflows.
>
> Except that meanwhile Don agreed with my statement that neither
> this nor the two earlier patches really fix the issue. So rather than
> pushing this into 3.16 and stable trees, I wonder whether the two
> earlier ones shouldn't be reverted and then a clean and correct
> fix be applied.
So here's a patch which I think adds the missing pieces.
Jan
lz4: check for underruns
While overruns are already being taken care of, underruns (resulting
from overflows in the respective "op + length" (or similar) operations
weren't. Fix this, allowing commits 4a3a990451, 4148c1f67a, and
206204a116 to be reverted (perhaps apart from the return value
adjustments two of the three do).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
The patch applies correctly with or without said reverts carried out.
--- a/lib/lz4/lz4_decompress.c
+++ b/lib/lz4/lz4_decompress.c
@@ -89,6 +89,8 @@ static int lz4_uncompress(const char *so
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;
@@ -147,6 +149,8 @@ static int lz4_uncompress(const char *so
goto _output_error;
continue;
}
+ if (unlikely((unsigned long)cpy < (unsigned long)op))
+ goto _output_error;
LZ4_SECURECOPY(ref, op, cpy);
op = cpy; /* correction */
}
@@ -209,6 +213,8 @@ static int lz4_uncompress_unknownoutputs
op += length;
break;/* Necessarily EOF, due to parsing restrictions */
}
+ if (unlikely((unsigned long)cpy < (unsigned long)op))
+ goto _output_error;
LZ4_WILDCOPY(ip, op, cpy);
ip -= (op - cpy);
op = cpy;
@@ -272,6 +278,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 = cpy; /* correction */
}
next prev parent reply other threads:[~2014-07-04 13:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 23:11 Greg KH
2014-07-04 6:12 ` Jan Beulich
2014-07-04 13:01 ` Jan Beulich [this message]
2014-07-25 6:00 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53B6C1D70200007800020BE7@mail.emea.novell.com \
--to=jbeulich@suse.com \
--cc=donb@securitymouse.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®