]> Git Repo - linux.git/commit - fs/btrfs/volumes.c
btrfs: handle missing chunk mapping more gracefully
authorQu Wenruo <[email protected]>
Thu, 2 Mar 2023 01:54:12 +0000 (09:54 +0800)
committerDavid Sterba <[email protected]>
Wed, 15 Mar 2023 19:51:05 +0000 (20:51 +0100)
commit1c3ab6dfa0692c3626580a508cf84e794201b357
tree6469490346f90c90aafea80c5a5b97d0fddae517
parent675dfe1223a69e270b3d52cb0211c8a501455cec
btrfs: handle missing chunk mapping more gracefully

[BUG]
During my scrub rework, I did a stupid thing like this:

        bio->bi_iter.bi_sector = stripe->logical;
        btrfs_submit_bio(fs_info, bio, stripe->mirror_num);

Above bi_sector assignment is using logical address directly, which
lacks ">> SECTOR_SHIFT".

This results a read on a range which has no chunk mapping.

This results the following crash:

  BTRFS critical (device dm-1): unable to find logical 11274289152 length 65536
  assertion failed: !IS_ERR(em), in fs/btrfs/volumes.c:6387

Sure this is all my fault, but this shows a possible problem in real
world, that some bit flip in file extents/tree block can point to
unmapped ranges, and trigger above ASSERT(), or if CONFIG_BTRFS_ASSERT
is not configured, cause invalid pointer access.

[PROBLEMS]
In the above call chain, we just don't handle the possible error from
btrfs_get_chunk_map() inside __btrfs_map_block().

[FIX]
The fix is straightforward, replace the ASSERT() with proper error
handling (callers handle errors already).

Reviewed-by: Anand Jain <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
Signed-off-by: David Sterba <[email protected]>
fs/btrfs/volumes.c
This page took 0.056941 seconds and 4 git commands to generate.