From: Richard Weinberger <richard@nod.at>
To: Chengsong Ke <kechengsong@huawei.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>,
linux-mtd <linux-mtd@lists.infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
wangfangpeng1@huawei.com, chengzhihao1 <chengzhihao1@huawei.com>
Subject: Re: [PATCH] ubifs: Fix read out-of-bounds in ubifs_jnl_write_inode()
Date: Wed, 23 Dec 2020 11:00:13 +0100 (CET) [thread overview]
Message-ID: <135307670.158287.1608717613022.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <20201223062808.27512-1-kechengsong@huawei.com>
Chengsong Ke,
----- Ursprüngliche Mail -----
> The memory area allocated in ubifs_jnl_write_inode() is not aligned with 8
> bytes:
> ino_start = ino = kmalloc(write_len, GFP_NOFS);
>
> When ino_start passed into write_head -> ubifs_wbuf_write_nolock:
> n = aligned_len >> c->max_write_shift;
> if (n) {
> n <<= c->max_write_shift;
> err = ubifs_leb_write(c, wbuf->lnum, buf + written, wbuf->offs, n);
> // Read oob occurs here, read n bytes from buf, and buf is passed from
> @ino_start which is
> // not 8 bytes aligned(write_len < n). Program read (n - write_len) more bytes.
> }
>
> Reproducer:
> 0. config KASAN && apply print.patch
> 1. mount ubifs on /root/temp
> 2. run test.sh
> 3. cd /root/temp && ls // change atime for link_file
> 4. wait 1~2 minutes
>
> Cc: <stable@vger.kernel.org>
> Fixes: 1e51764a3c2ac0 ("UBIFS: add new flash file system")
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=210865
>
> Signed-off-by: Chengsong Ke <kechengsong@huawei.com>
> ---
> fs/ubifs/io.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
Good catch!
Please address the problem in ubifs_jnl_write_inode().
The length there needs to be properly aligned like all other journal
functions do.
I think you managed to trigger the issue because ui->data_len is not aligned.
Thanks,
//richard
prev parent reply other threads:[~2020-12-23 10:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-23 6:28 Chengsong Ke
2020-12-23 6:59 ` Zhihao Cheng
2020-12-23 10:00 ` Richard Weinberger [this message]
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=135307670.158287.1608717613022.JavaMail.zimbra@nod.at \
--to=richard@nod.at \
--cc=chengzhihao1@huawei.com \
--cc=kechengsong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
--cc=wangfangpeng1@huawei.com \
/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
Powered by JetHome