linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jun Nie <jun.nie@linaro.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	tudor.ambarus@linaro.org
Subject: Re: [PATCH] ext4: reject 1k block fs on the first block of disk
Date: Wed, 4 Jan 2023 09:58:03 +0800	[thread overview]
Message-ID: <CABymUCPCT9KbMQDUTxwf6A+Cg9fWJNkefbMHD7SZD3Fc7FMFHg@mail.gmail.com> (raw)
In-Reply-To: <Y7R/QKIbYQ2TCP+W@magnolia>

Darrick J. Wong <djwong@kernel.org> 于2023年1月4日周三 03:17写道:
>
> On Thu, Dec 29, 2022 at 09:45:02AM +0800, Jun Nie wrote:
> > For 1k-block filesystems, the filesystem starts at block 1, not block 0.
> > If start_fsb is 0, it will be bump up to s_first_data_block. Then
> > ext4_get_group_no_and_offset don't know what to do and return garbage
> > results (blockgroup 2^32-1). The underflow make index
> > exceed es->s_groups_count in ext4_get_group_info() and trigger the BUG_ON.
> >
> > Fixes: 4a4956249dac0 ("ext4: fix off-by-one fsmap error on 1k block filesystems")
> > Link: https://syzkaller.appspot.com/bug?id=79d5768e9bfe362911ac1a5057a36fc6b5c30002
> > Reported-by: syzbot+6be2b977c89f79b6b153@syzkaller.appspotmail.com
> > Signed-off-by: Jun Nie <jun.nie@linaro.org>
> > ---
> >  fs/ext4/fsmap.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c
> > index 4493ef0c715e..1aef127b0634 100644
> > --- a/fs/ext4/fsmap.c
> > +++ b/fs/ext4/fsmap.c
> > @@ -702,6 +702,12 @@ int ext4_getfsmap(struct super_block *sb, struct ext4_fsmap_head *head,
> >               if (handlers[i].gfd_dev > head->fmh_keys[0].fmr_device)
> >                       memset(&dkeys[0], 0, sizeof(struct ext4_fsmap));
> >
> > +             /*
> > +              * Re-check the range after above limit operation and reject
> > +              * 1K fs on block 0 as fs should start block 1. */
> > +             if (dkeys[0].fmr_physical ==0 && dkeys[1].fmr_physical == 0)
> > +                     continue;
>
> ...and if this filesystem has 4k blocks, and therefore *does* define a
> block 0?

Yes, this is a real corner case test :-)

>
> --D
>
> > +
> >               info.gfi_dev = handlers[i].gfd_dev;
> >               info.gfi_last = false;
> >               info.gfi_agno = -1;
> > --
> > 2.34.1
> >

  reply	other threads:[~2023-01-04  1:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-29  1:45 [PATCH] ext4: reject 1k block fs on the first block of disk Jun Nie
2023-01-03 19:17 ` Darrick J. Wong
2023-01-04  1:58   ` Jun Nie [this message]
2023-02-15  4:32     ` Theodore Ts'o
2023-02-15 11:46       ` Tudor Ambarus
2023-02-15 11:53         ` Tudor Ambarus
2023-02-15 16:26           ` Tudor Ambarus
2023-02-22 15:27       ` Tudor Ambarus

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=CABymUCPCT9KbMQDUTxwf6A+Cg9fWJNkefbMHD7SZD3Fc7FMFHg@mail.gmail.com \
    --to=jun.nie@linaro.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=djwong@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tudor.ambarus@linaro.org \
    --cc=tytso@mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).