public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz, Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 6/6] btrfs-progs: extent-tree: Fix a by-one error in exclude_super_stripes()
Date: Fri, 3 Jan 2020 08:42:12 +0800	[thread overview]
Message-ID: <eb9033f0-c390-0d83-07a6-63e89cb2020b@gmx.com> (raw)
In-Reply-To: <20200102165603.GL3929@twin.jikos.cz>


[-- Attachment #1.1: Type: text/plain, Size: 2017 bytes --]



On 2020/1/3 上午12:56, David Sterba wrote:
> On Wed, Dec 18, 2019 at 09:19:42AM +0800, Qu Wenruo wrote:
>> [BUG]
>> For certain btrfs images, a BUG_ON() can be triggered at open_ctree()
>> time:
>>   Opening filesystem to check...
>>   extent_io.c:158: insert_state: BUG_ON `end < start` triggered, value 1
>>   btrfs(+0x2de57)[0x560c4d7cfe57]
>>   btrfs(+0x2e210)[0x560c4d7d0210]
>>   btrfs(set_extent_bits+0x254)[0x560c4d7d0854]
>>   btrfs(exclude_super_stripes+0xbf)[0x560c4d7c65ff]
>>   btrfs(btrfs_read_block_groups+0x29d)[0x560c4d7c698d]
>>   btrfs(btrfs_setup_all_roots+0x3f3)[0x560c4d7c0b23]
>>   btrfs(+0x1ef53)[0x560c4d7c0f53]
>>   btrfs(open_ctree_fs_info+0x90)[0x560c4d7c11a0]
>>   btrfs(+0x6d3f9)[0x560c4d80f3f9]
>>   btrfs(main+0x94)[0x560c4d7b60c4]
>>   /usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7fd189773ee3]
>>   btrfs(_start+0x2e)[0x560c4d7b635e]
>>
>> [CAUSE]
>> This is caused by passing @len == 0 to add_excluded_extent(), which
>> means one revsere mapped range is just out of the block group range,
>> normally means a by-one error.
>>
>> [FIX]
>> Fix the boundary check on the reserve mapped range against block group
>> range.
>> If a reverse mapped super block starts at the end of the block group, it
>> doesn't cover so we don't need to bother the case.
>>
>> Issue: #210
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>  extent-tree.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/extent-tree.c b/extent-tree.c
>> index 6288c8a3..7ba80375 100644
>> --- a/extent-tree.c
>> +++ b/extent-tree.c
>> @@ -3640,7 +3640,7 @@ int exclude_super_stripes(struct btrfs_fs_info *fs_info,
>>  		while (nr--) {
>>  			u64 start, len;
>>  
>> -			if (logical[nr] > cache->key.objectid +
>> +			if (logical[nr] >= cache->key.objectid +
>>  			    cache->key.offset)
> 
> Do we have the same problem in kernel? The code does ">".
> 
Oh, kernel looks to have the same problem.

Time to fix it.

Thanks,
Qu


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]

  reply	other threads:[~2020-01-03  0:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18  1:19 [PATCH 0/6] btrfs-progs: Fixes for github issues Qu Wenruo
2019-12-18  1:19 ` [PATCH 1/6] btrfs-progs: tests: Add --force for repair command Qu Wenruo
2019-12-18  1:19 ` [PATCH 2/6] btrfs-progs: check/original: Do extra verification on file extent item Qu Wenruo
2019-12-18  2:09   ` Su Yue
2019-12-18  2:17     ` Qu Wenruo
2019-12-18  2:19       ` Su Yue
2019-12-18  1:19 ` [PATCH 3/6] btrfs-progs: disk-io: Verify the bytenr passed in is mapped for read_tree_block() Qu Wenruo
2019-12-18  1:19 ` [PATCH 4/6] btrfs-progs: Add extra chunk item size check Qu Wenruo
2019-12-18  1:19 ` [PATCH 5/6] btrfs-progs: extent-tree: Kill the BUG_ON() in btrfs_chunk_readonly() Qu Wenruo
2019-12-18  1:19 ` [PATCH 6/6] btrfs-progs: extent-tree: Fix a by-one error in exclude_super_stripes() Qu Wenruo
2020-01-02 16:56   ` David Sterba
2020-01-03  0:42     ` Qu Wenruo [this message]
2020-01-03  3:04       ` Su Yue
2020-01-02 17:10 ` [PATCH 0/6] btrfs-progs: Fixes for github issues David Sterba
2020-01-03  0:43   ` Qu Wenruo
2020-01-03 15:27     ` David Sterba
2020-01-04  1:26       ` Qu Wenruo
2020-01-06 15:45         ` David Sterba
2020-01-07  1:46           ` Qu Wenruo

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=eb9033f0-c390-0d83-07a6-63e89cb2020b@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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