From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Juntong Deng <juntong.deng@outlook.com>, cuigaosheng1@huawei.com
Cc: jfs-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
syzbot+76a072c2f8a60280bd70@syzkaller.appspotmail.com
Subject: Re: [PATCH] fs/jfs: Add checking for out-of-bounds index in binary search in xtSearch
Date: Tue, 3 Oct 2023 18:36:25 -0500 [thread overview]
Message-ID: <5d03f98a-262e-441c-812e-8257d66680c5@oracle.com> (raw)
In-Reply-To: <VI1P193MB0752266E3E55B2D918F8E43799C4A@VI1P193MB0752.EURP193.PROD.OUTLOOK.COM>
On 10/3/23 5:49AM, Juntong Deng wrote:
> There is currently no out-of-bounds check for the index in a binary
> search, which may cause errors.
>
> The following is related bug reported by Syzbot:
>
> UBSAN: array-index-out-of-bounds in fs/jfs/jfs_xtree.c:360:4
> index 18 is out of range for type 'xad_t [18]'
>
> Checking if the index exceeds the size of the xad array can solve
> this bug.
This won't work for the same reason I talk about here:
https://sourceforge.net/p/jfs/mailman/message/40826617/
The xad array can be either XTROOTMAXSLOT or XTPAGEMAXSLOT entries long
and it is declared with the smaller number since it's included in the
inode. I will fix the declarations so that we can use the larger number
without triggering code checkers.
Thanks,
Shaggy
>
> Reported-by: syzbot+76a072c2f8a60280bd70@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=76a072c2f8a60280bd70
> Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
> ---
> fs/jfs/jfs_xtree.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
> index 2d304cee884c..6b55bb1e4089 100644
> --- a/fs/jfs/jfs_xtree.c
> +++ b/fs/jfs/jfs_xtree.c
> @@ -356,6 +356,8 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
> */
> for (base = XTENTRYSTART; lim; lim >>= 1) {
> index = base + (lim >> 1);
> + if (index >= XTROOTMAXSLOT)
> + break;
>
> XT_CMP(cmp, xoff, &p->xad[index], t64);
> if (cmp == 0) {
prev parent reply other threads:[~2023-10-03 23:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-03 10:49 Juntong Deng
2023-10-03 23:36 ` Dave Kleikamp [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=5d03f98a-262e-441c-812e-8257d66680c5@oracle.com \
--to=dave.kleikamp@oracle.com \
--cc=cuigaosheng1@huawei.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=juntong.deng@outlook.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+76a072c2f8a60280bd70@syzkaller.appspotmail.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
all inboxes | Powered by JetHome®