From: Alan Huang <mmpgouride@gmail.com>
To: Hongbo Li <lihongbo22@huawei.com>
Cc: Jeongjun Park <aha310510@gmail.com>,
Kent Overstreet <kent.overstreet@linux.dev>,
linux-bcachefs@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
syzbot+7f45fa9805c40db3f108@syzkaller.appspotmail.com
Subject: Re: [PATCH v3] bcachefs: fix shift oob in alloc_lru_idx_fragmentation
Date: Tue, 22 Oct 2024 10:38:28 +0800 [thread overview]
Message-ID: <45EF275D-8F04-41DF-9895-CCAF28D5AAAC@gmail.com> (raw)
In-Reply-To: <1e46f070-3e78-4a81-b7c7-ea021271b12b@huawei.com>
On Oct 22, 2024, at 10:26, Hongbo Li <lihongbo22@huawei.com> wrote:
>
>
>
> On 2024/10/21 23:43, Jeongjun Park wrote:
>> The size of a.data_type is set abnormally large, causing shift-out-of-bounds.
>> To fix this, we need to add validation on a.data_type in
>> alloc_lru_idx_fragmentation().
>> Reported-by: syzbot+7f45fa9805c40db3f108@syzkaller.appspotmail.com
>> Fixes: 260af1562ec1 ("bcachefs: Kill alloc_v4.fragmentation_lru")
>> Signed-off-by: Jeongjun Park <aha310510@gmail.com>
>> ---
>> fs/bcachefs/alloc_background.h | 3 +++
>> 1 file changed, 3 insertions(+)
>> diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h
>> index f8e87c6721b1..163a67b97a40 100644
>> --- a/fs/bcachefs/alloc_background.h
>> +++ b/fs/bcachefs/alloc_background.h
>> @@ -168,6 +168,9 @@ static inline bool data_type_movable(enum bch_data_type type)
>> static inline u64 alloc_lru_idx_fragmentation(struct bch_alloc_v4 a,
>> struct bch_dev *ca)
>> {
>> + if (a.data_type >= BCH_DATA_NR)
>> + return 0;
>> +
>
> oh, I found I have done the same thing in [1]("Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_alloc_to_text"). But
Your patch there is still triggering the issue.
> in my humble opinion, the validation changes also should be added. And in addition, move the condition about a.data_type into
There is already the validation:
bkey_fsck_err_on(alloc_data_type(a, a.data_type) != a.data_type
And the unknown data type is already printed in bch2_prt_data_type, additional validation doesn’t help much.
> data_type_movable will be better. Just my personal opinion.:)
In my personal opinion, I don’t think so :)
>
> [1] https://www.spinics.net/lists/kernel/msg5412619.html
>
> Thanks,
> Hongbo
>
>> if (!data_type_movable(a.data_type) ||
>> !bch2_bucket_sectors_fragmented(ca, a))
>> return 0;
>> --
next prev parent reply other threads:[~2024-10-22 2:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 15:43 [PATCH v3] bcachefs: fix shift oob in alloc_lru_idx_fragmentation Jeongjun Park
2024-10-22 2:26 ` Hongbo Li
2024-10-22 2:38 ` Alan Huang [this message]
2024-10-22 3:05 ` Hongbo Li
2024-10-22 3:23 ` Alan Huang
2024-10-22 4:05 ` Jeongjun Park
2024-10-23 1:11 ` Hongbo Li
2024-10-24 11:30 ` Kent Overstreet
2024-10-24 11:30 ` Kent Overstreet
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=45EF275D-8F04-41DF-9895-CCAF28D5AAAC@gmail.com \
--to=mmpgouride@gmail.com \
--cc=aha310510@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=lihongbo22@huawei.com \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+7f45fa9805c40db3f108@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