Skip to content

btrfs: Enhanced runtime defence against fuzzed images

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5btrfs: extent_io: Do extra check for extent buffer read write functionsfs/btrfs/extent_io.c+42 -375 replies
2/5btrfs: extent-tree: Kill BUG_ON() in __btrfs_free_extent() and do better commentfs/btrfs/extent-tree.c+131 -132 replies
3/5btrfs: Detect unbalanced tree with empty leaf before crashing btree operationsfs/btrfs/disk-io.c fs/btrfs/tree-checker.c+15 -01 reply
4/5btrfs: extent-tree: Kill the BUG_ON() in insert_inline_extent_backref()fs/btrfs/extent-tree.c+22 -21 reply
5/5btrfs: ctree: Checking key orders before merged tree blocksfs/btrfs/ctree.c+63 -04 replies

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by.

PatchNikolay Borisov
1/5
2/5
3/5
4/5
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] btrfs: Enhanced runtime defence against fuzzed images

Another wave of defence enhancment, including:

- Enhanced eb accessors
Not really needed for the fuzzed images, as 448de471cd4c ("btrfs: Check the first key and level for cached extent buffer") already fixed half of the reported images.
Just add a final layer of safe net.

- BUG_ON() hunt in __btrfs_free_extent()
Kill BUG_ON()s in __btrfs_free_extent(), replace with error reporting and why it shouldn't happen.

Also add comment on what __btrfs_free_extent() is designed to do, with two dump-tree examples for newcomers.

- BUG_ON() hunt in __btrfs_inc_extent_ref()
Just like __btrfs_free_extent(), but less comment as comment for __btrfs_free_extent() should also work for __btrfs_inc_extent_ref(), and __btrfs_inc_extent_ref() has a better structure than __btrfs_free_extent().

- Defence against unbalanced empty leaf

- Defence against bad key order across two tree blocks

The last two cases can't be rejected by tree-checker and they are all cross-eb cases.
Thankfully we can reuse existing first_key check against unbalanced empty leaf, but needs extra check deep into ctree.c for tree block merging time check.

[ Not to mail bombarding the report, thus only RB tag in cover letter ]

Qu Wenruo (5):
btrfs: extent_io: Do extra check for extent buffer read write
functions
btrfs: extent-tree: Kill BUG_ON() in __btrfs_free_extent() and do
better comment
btrfs: Detect unbalanced tree with empty leaf before crashing btree
operations
btrfs: extent-tree: Kill the BUG_ON() in
insert_inline_extent_backref()
btrfs: ctree: Checking key orders before merged tree blocks

 fs/btrfs/ctree.c        |  63 +++++++++++++++
 fs/btrfs/disk-io.c      |   9 +++
 fs/btrfs/extent-tree.c  | 168 ++++++++++++++++++++++++++++++++++++----
 fs/btrfs/extent_io.c    |  79 ++++++++++---------
 fs/btrfs/tree-checker.c |   6 ++
 5 files changed, 273 insertions(+), 52 deletions(-)
Signature · 1 line
2.22.0