From: Hou Tao <houtao1@huawei.com>
To: Richard Weinberger <richard@nod.at>, <linux-mtd@lists.infradead.org>
Cc: <dwmw2@infradead.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] jffs2: Fix integer underflow in jffs2_rtime_compress
Date: Thu, 20 Dec 2018 18:43:08 +0800 [thread overview]
Message-ID: <cae86ca1-91f9-6728-df64-40580145220d@huawei.com> (raw)
In-Reply-To: <20181215162350.12489-1-richard@nod.at>
On 2018/12/16 0:23, Richard Weinberger wrote:
> The rtime compressor assumes that at least two bytes are
> compressed.
> If we try to compress just one byte, the loop condition will
> wrap around and an out-of-bounds write happens.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> fs/jffs2/compr_rtime.c | 3 +++
> 1 file changed, 3 insertions(+)
> It seems that it doesn't incur any harm because the minimal allocated
size will be 8-bytes and jffs2_rtime_compress() will write 2-bytes into
the allocated buffer.
> diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c
> index 406d9cc84ba8..cbf700001fc9 100644
> --- a/fs/jffs2/compr_rtime.c
> +++ b/fs/jffs2/compr_rtime.c
> @@ -39,6 +39,9 @@ static int jffs2_rtime_compress(unsigned char *data_in,
>
> memset(positions,0,sizeof(positions));
>
> + if (*dstlen < 2)
> + return -1;
> +
> while (pos < (*sourcelen) && outpos <= (*dstlen)-2) {
> int backpos, runlen=0;
> unsigned char value;
>
next prev parent reply other threads:[~2018-12-20 10:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-15 16:23 [PATCH] jffs2: Fix integer underflow in jffs2_rtime_compress Richard Weinberger
2018-12-20 10:43 ` Hou Tao [this message]
2018-12-20 10:45 ` Richard Weinberger
2020-01-23 2:24 ` Hou Tao
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=cae86ca1-91f9-6728-df64-40580145220d@huawei.com \
--to=houtao1@huawei.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--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;
as well as URLs for NNTP newsgroup(s).