Skip to content

btrfs: tree-checker: More enhancement for fuzzed

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest9 patches 32 repliesIn review

Changes in v2 from the cover letter

- Split patches for btrfs_check_chunk_valid() merge into tree-checker.
- Rebase to v5.1-rc1 based write_time_tree_checker branch.
- Add reviewed-by tags.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9btrfs: Move btrfs_check_chunk_valid() to tree-check.[ch] and export itfs/btrfs/tree-checker.c fs/btrfs/tree-checker.h fs/btrfs/volumes.c+103 -934 replies
2/9btrfs: tree-checker: Make chunk item checker more readablefs/btrfs/tree-checker.c+68 -132 replies
3/9btrfs: tree-checker: Make btrfs_check_chunk_valid() return EUCLEAN instead of EIOfs/btrfs/tree-checker.c+10 -101 reply
4/9btrfs: tree-checker: Check chunk item at tree block read timefs/btrfs/tree-checker.c fs/btrfs/volumes.c+15 -31 reply
5/9btrfs: tree-checker: Verify dev itemfs/btrfs/tree-checker.c fs/btrfs/volumes.c fs/btrfs/volumes.h+92 -94 replies
6/9btrfs: Check the first key and level for cached extent bufferfs/btrfs/ctree.c fs/btrfs/disk-io.c fs/btrfs/disk-io.h+18 -51 reply
7/9btrfs: tree-checker: Enhance chunk checker to validate chunk profilerfs/btrfs/tree-checker.c+7 -01 reply
8/9btrfs: tree-checker: Verify inode itemfs/btrfs/ctree.h fs/btrfs/tree-checker.c+101 -013 replies
9/9btrfs: inode: Verify inode mode to avoid NULL pointer dereferencefs/btrfs/inode.c fs/btrfs/tests/inode-tests.c+31 -84 replies

Reviews trailers per patch

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

PatchNikolay BorisovJohannes Thumshirn
1/9R-b
2/9R-b
3/9R-b
4/9R-b
5/9R-b
6/9R-b R-b
7/9R-b R-b
8/9R-b R-b
9/9R-b R-b

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

Read the v2 thread

Cover letter [PATCh v2 0/9] btrfs: tree-checker: More enhancement for fuzzed

This patchset can be fetched from github:
It can be fetched from github:
https://github.com/adam900710/linux/tree/tree_checker_enhancement
Which is based on my previous write time tree checker patchset (based on v5.1-rc1 tag)

Thanks for the report from Yoon Jungyeon <[email protected]>, we have more fuzzed image to torture btrfs.

Those images exposed the following problems:

- Chunk check is not comprehensive nor early enough
Chunk item check lacks profile bits check (e.g RAID|DUP profile is invalid).
And for certain fuzzed image, the other copy can be valid, current check timming is after tree block read, so no way to retry the other copy.

Address the check timing in the 1st~4th patch, while for the profile bits, check it in the 7th patch.

- Lack of device item check
Address it in the 5nd patch.

- First key and level check be exploited by cached extent buffer Cached bad extent buffer can avoid first key and level check. This is addressed in the 6rd patch.

- Inode type mismatch can lead to NULL dereference in endio function If an inode claims itself as symlink but still has regular file extent, then endio function will cause NULL pointer dereference. Fix it by do extra inode mode and dir item type cross check, at get_extent() time and inode lookup time.
Addressed in the last 2 patches.

Changelog:
v2:
- Split patches for btrfs_check_chunk_valid() merge into tree-checker.
- Rebase to v5.1-rc1 based write_time_tree_checker branch.
- Add reviewed-by tags.

Qu Wenruo (9):
btrfs: Move btrfs_check_chunk_valid() to tree-check.[ch] and export it
btrfs: tree-checker: Make chunk item checker more readable
btrfs: tree-checker: Make btrfs_check_chunk_valid() return EUCLEAN
instead of EIO
btrfs: tree-checker: Check chunk item at tree block read time
btrfs: tree-checker: Verify dev item
btrfs: Check the first key and level for cached extent buffer
btrfs: tree-checker: Enhance chunk checker to validate chunk profiler
btrfs: tree-checker: Verify inode item
btrfs: inode: Verify inode mode to avoid NULL pointer dereference

 fs/btrfs/ctree.c             |  10 +
 fs/btrfs/ctree.h             |   2 +
 fs/btrfs/disk-io.c           |  10 +-
 fs/btrfs/disk-io.h           |   3 +
 fs/btrfs/inode.c             |  38 +++-
 fs/btrfs/tests/inode-tests.c |   1 +
 fs/btrfs/tree-checker.c      | 349 +++++++++++++++++++++++++++++++++++
 fs/btrfs/tree-checker.h      |   3 +
 fs/btrfs/volumes.c           | 115 +-----------
 fs/btrfs/volumes.h           |   9 +
 10 files changed, 422 insertions(+), 118 deletions(-)
Signature · 1 line
2.21.0