From: Manas Ghandat <ghandatmanas@gmail.com>
To: Dave Kleikamp <dave.kleikamp@oracle.com>,
shaggy@kernel.org, liushixin2@huawei.com
Cc: linux-kernel@vger.kernel.org,
jfs-discussion@lists.sourceforge.net,
Linux-kernel-mentees@lists.linuxfoundation.org,
syzbot+aea1ad91e854d0a83e04@syzkaller.appspotmail.com
Subject: Re: [PATCH] jfs: fix array-index-out-of-bounds in dbFindLeaf
Date: Thu, 31 Aug 2023 20:49:09 +0530 [thread overview]
Message-ID: <ae6ce935-96eb-3d40-f252-54fff7eb0ea9@gmail.com> (raw)
In-Reply-To: <e62dbf53-9d74-45e5-b44e-53140672b8b5@oracle.com>
I was wondering if we could implement a get_tree_size macro wherein we
could find the tree size so that we can do the comparison. SInce the
tp->dmt_stree is an array we can get its size and fix the out of bounds.
Would this thing work?
On 30/08/23 00:08, Dave Kleikamp wrote:
> This won't work. dbFindLeaf() can be called from dbFindCtl() with
> struct dmapctl whose stree index can be as high as CTLTREESIZE which
> is larger than TREESIZE. A check against CTLTREESIZE might be better
> than nothing at all but won't necessarily detect an overflow.
> Currently, dbFindLeaf doesn't have anything to tell it which tree it
> is working on.
>
> We could pass in the treesize as an argument to dbFindCtl() if we
> can't come up with something simpler.
>
> Shaggy
>
>>
>> Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
>> Reported-by: syzbot+aea1ad91e854d0a83e04@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?extid=aea1ad91e854d0a83e04
>> ---
>> fs/jfs/jfs_dmap.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
>> index a14a0f18a4c4..5af17b2287be 100644
>> --- a/fs/jfs/jfs_dmap.c
>> +++ b/fs/jfs/jfs_dmap.c
>> @@ -2948,6 +2948,10 @@ static int dbFindLeaf(dmtree_t * tp, int l2nb,
>> int *leafidx)
>> /* sufficient free space found. move to the next
>> * level (or quit if this is the last level).
>> */
>> +
>> + if (x + n > TREESIZE)
>> + return -ENOSPC;
>> +
>> if (l2nb <= tp->dmt_stree[x + n])
>> break;
>> }
next prev parent reply other threads:[~2023-08-31 15:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 16:52 Manas Ghandat
2023-08-29 18:38 ` Dave Kleikamp
2023-08-31 15:19 ` Manas Ghandat [this message]
2023-09-01 17:08 ` Dave Kleikamp
2023-09-02 17:45 ` Manas Ghandat
2023-09-03 21:45 ` Dave Kleikamp
2026-02-04 9:22 syzbot
2026-02-23 14:36 ` Dmitry Vyukov
2026-03-02 17:50 ` Dave Kleikamp
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=ae6ce935-96eb-3d40-f252-54fff7eb0ea9@gmail.com \
--to=ghandatmanas@gmail.com \
--cc=Linux-kernel-mentees@lists.linuxfoundation.org \
--cc=dave.kleikamp@oracle.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=liushixin2@huawei.com \
--cc=shaggy@kernel.org \
--cc=syzbot+aea1ad91e854d0a83e04@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®