From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Johannes Thumshirn <jthumshirn@suse.de>, David Sterba <dsterba@suse.com>
Cc: Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>,
Liu Bo <obuil.liubo@gmail.com>
Subject: Re: [PATCH] btrfs: ensure that a DUP block group has exactly two stripes
Date: Wed, 13 Feb 2019 22:32:22 +0800 [thread overview]
Message-ID: <7a137a90-aa8e-f170-a34f-5166a4e41ce5@gmx.com> (raw)
In-Reply-To: <20190213142602.20436-1-jthumshirn@suse.de>
[-- Attachment #1.1: Type: text/plain, Size: 1878 bytes --]
On 2019/2/13 下午10:26, Johannes Thumshirn wrote:
> We recently had a customer issue with a corrupted filesystem. When trying
> to mount this image btrfs panicked with a division by zero in
> calc_stripe_length().
>
> The corrupt chunk had a 'num_stripes' value of 1. calc_stripe_length()
> takes this value and divides it by the number of copies the RAID profile is
> expected to have to calculate the amount of data stripes. As a DUP profile
> is expected to have 2 copies this division resulted in 1/2 = 0. Later then
> the 'data_stripes' variable is used as a divisor in the stripe length
> calculation which results in a division by 0 and thus a kernel panic.
>
> When encountering a filesystem with a DUP block group and a 'num_stripes'
> value unequal to 2, refuse mounting as the image is corrupted and will lead
> to unexpected behaviour.
>
> Fixes: e06cd3dd7cea ("Btrfs: add validadtion checks for chunk loading")
> Cc: Liu Bo <obuil.liubo@gmail.com>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/volumes.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 03f223aa7194..b40cc7c830f4 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -6794,7 +6794,7 @@ static int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
> (type & BTRFS_BLOCK_GROUP_RAID1 && num_stripes < 1) ||
> (type & BTRFS_BLOCK_GROUP_RAID5 && num_stripes < 2) ||
> (type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes < 3) ||
> - (type & BTRFS_BLOCK_GROUP_DUP && num_stripes > 2) ||
> + (type & BTRFS_BLOCK_GROUP_DUP && num_stripes != 2) ||
> ((type & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0 &&
> num_stripes != 1)) {
> btrfs_err(fs_info,
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-02-13 14:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-13 14:26 [PATCH] btrfs: ensure that a DUP block group has exactly two stripes Johannes Thumshirn
2019-02-13 14:27 ` Nikolay Borisov
2019-02-13 14:32 ` Qu Wenruo [this message]
2019-02-13 14:32 ` Hans van Kranenburg
2019-02-13 14:37 ` Johannes Thumshirn
2019-02-13 15:02 ` Nikolay Borisov
2019-02-14 17:27 ` Hans van Kranenburg
2019-02-14 16:21 ` Johannes Thumshirn
2019-02-15 15:20 ` David Sterba
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=7a137a90-aa8e-f170-a34f-5166a4e41ce5@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=dsterba@suse.com \
--cc=jthumshirn@suse.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=obuil.liubo@gmail.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;
as well as URLs for NNTP newsgroup(s).