Skip to content

Enhancement for block group/chunk verification

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 25 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5btrfs: tree-checker: Verify block_group_itemfs/btrfs/tree-checker.c fs/btrfs/volumes.c fs/btrfs/volumes.h+104 -13 replies
2/5btrfs: tree-checker: Detect invalid empty essential treefs/btrfs/tree-checker.c+12 -03 replies
3/5btrfs: relocation: Only remove reloc rb_trees if reloc control has been initializedfs/btrfs/relocation.c+12 -112 replies
4/5btrfs: Check each block group has corresponding chunk at mount timefs/btrfs/extent-tree.c+53 -23 replies
5/5btrfs: Verify every chunk has corresponding block group at mount timefs/btrfs/extent-tree.c+51 -111 replies

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchGu JinxiangNikolay Borisov
1/5R-b T-b R-b
2/5R-b T-b
3/5R-b T-b
4/5R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] Enhancement for block group/chunk verification

Can be fetched from github, which is based on v4.18-rc1 tag:
https://github.com/adam900710/linux/tree/tree_checker_enhance

Reported by Xu Wen <[email protected]>, some crafted btrfs image can cause unexpected kernel behavior.

All of them are related to block group and chunk, so this patchset will enhance block group and chunk verification, so kernel can detect them and error out gracefully (with user friendly error message showing what's going wrong)

Obvious corruption (don't need to cross check with chunk/block group), will be addressed by enhanced tree-checker.
(Most crafted images will be caught by tree-checker)

More complex corruption will be addressed mostly at btrfs_read_block_groups(), doing extra cross reference check for chunk<->block group mapping.
It may cause extra mount time, but compared to the existing time consuming block group items search, all added check is done completely in memory using rb_tree, so it shouldn't add too much overhead.

Qu Wenruo (5):
btrfs: tree-checker: Verify block_group_item
btrfs: tree-checker: Detect invalid empty essential tree
btrfs: relocation: Only remove reloc rb_trees if reloc control has
been initialized
btrfs: Check each block group has corresponding chunk at mount time
btrfs: Verify every chunk has corresponding block group at mount time

 fs/btrfs/extent-tree.c  | 107 +++++++++++++++++++++++++++++++++++--
 fs/btrfs/relocation.c   |  23 ++++----
 fs/btrfs/tree-checker.c | 113 ++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/volumes.c      |   2 +-
 fs/btrfs/volumes.h      |   2 +
 5 files changed, 232 insertions(+), 15 deletions(-)
Signature · 1 line
2.18.0