From: Edward Adam Davis <eadavis@qq.com>
To: kent.overstreet@linux.dev
Cc: eadavis@qq.com, linux-bcachefs@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+064ce437a1ad63d3f6ef@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in member_to_text
Date: Sun, 8 Sep 2024 20:59:37 +0800 [thread overview]
Message-ID: <tencent_6FF377237A096263A9C4469779777566C805@qq.com> (raw)
In-Reply-To: <hqzhbzxbp3rjbal3z4kdwygvus76h22o2br3iwuzohgniivw5q@etyntoz75vyp>
On Wed, 4 Sep 2024 15:39:37 -0400, Kent Overstreet wrote:
> On Tue, Sep 03, 2024 at 10:13:02AM GMT, Edward Adam Davis wrote:
> > Because the value of m.btree_bitmap_shift is 69 in this case, it cause
> > shift-out-of-bounds in member_to_text.
> >
> > Add a check for btree_bitmap_shift in validate_member, when it bigger than 64
> > return -BCH_ERR_invalid_sb_members.
> > Simultaneously adjust the output mode of btree_bitmap_shift in member_to_text.
> >
> > #syz test
> >
> > diff --git a/fs/bcachefs/sb-members.c b/fs/bcachefs/sb-members.c
> > index 39196f2a4197..85a4245ea6a3 100644
> > --- a/fs/bcachefs/sb-members.c
> > +++ b/fs/bcachefs/sb-members.c
> > @@ -162,6 +162,12 @@ static int validate_member(struct printbuf *err,
> > return -BCH_ERR_invalid_sb_members;
> > }
> >
> > + if (m.btree_bitmap_shift > 64) {
>
> should be >=, no?
Yes, you are right, here should be "if (m.btree_bitmap_shift >= 64)"
>
> > + prt_printf(err, "device %u: too many big bitmap shift (got %u, max 64)",
> > + i, m.btree_bitmap_shift);
> > + return -BCH_ERR_invalid_sb_members;
> > + }
> > +
> > return 0;
> > }
> >
> > @@ -245,8 +251,7 @@ static void member_to_text(struct printbuf *out,
> > prt_printf(out, "(none)");
> > prt_newline(out);
> >
> > - prt_printf(out, "Btree allocated bitmap blocksize:\t");
> > - prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
> > + prt_printf(out, "Btree allocated bitmap shift: %d\t", m.btree_bitmap_shift);
> > prt_newline(out);
> >
> > prt_printf(out, "Btree allocated bitmap:\t");
BR,
Edward
next prev parent reply other threads:[~2024-09-08 13:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 18:57 syzbot
2024-09-03 2:13 ` Edward Adam Davis
2024-09-03 2:34 ` syzbot
2024-09-04 19:39 ` Kent Overstreet
2024-09-08 12:59 ` Edward Adam Davis [this message]
2024-09-08 14:14 ` Kent Overstreet
2024-09-08 13:10 ` [PATCH] bcachefs: Fix oob " Edward Adam Davis
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=tencent_6FF377237A096263A9C4469779777566C805@qq.com \
--to=eadavis@qq.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+064ce437a1ad63d3f6ef@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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®